php - Get twitter video mp4 url -
question working twitter api , when post includes video. twitter returns thumbnails urls , not main video file url. twitter returns such json:
["media_url"]=> string(86) "http://pbs.twimg.com/ext_tw_video_thumb/../pu/img/p1r5ic_7fn-lqnuk.jpg" ["media_url_https"]=> string(87) "https://pbs.twimg.com/ext_tw_video_thumb/.../pu/img/p1r5ic_7fn-lqnuk.jpg" ["url"]=> string(22) "http://t.co/uvil9kykf*" ["expanded_url"]=> string(63) "http://twitter.com/.../status/..../video/1" and first 2 jpgs, , other urls redirect straight post. using php information, vine.co there such code:
$dom = new domfinder($media_url); $video_cell = $dom->find("//meta[@property='twitter:player:stream']", 'content'); but twitter doesn't have such meta tags in , can't find way access video file. maybe know how mp4 url?
twitter staff has stated here won't supporting fetching videos using search. have fetch videos other call api.
let's have tweet fetched using search/tweets saved in $tweet
// check if tweet has media if (!empty($tweet->entities->media)) { $searcharray = array( "id" => $tweet->id, // id of tweet fetched "include_entities" => true // tells twitter api return videos , stuff ); // extended_entities $extendedentities = $connection->get("statuses/show", $searcharray); foreach($extendedentities->extended_entities->media $media){ var_dump($media->video_info->variants); } } example result
array (size=6) 0 => object(stdclass)[265] public 'bitrate' => int 832000 public 'content_type' => string 'video/webm' (length=10) public 'url' => string 'https://video.twimg.com/ext_tw_video/560049056895209473/pu/vid/480x480/gj_fzyk29r9dmpby.webm' (length=92) 1 => object(stdclass)[266] public 'bitrate' => int 832000 public 'content_type' => string 'video/mp4' (length=9) public 'url' => string 'https://video.twimg.com/ext_tw_video/560049056895209473/pu/vid/480x480/gj_fzyk29r9dmpby.mp4' (length=91) 2 => object(stdclass)[267] public 'bitrate' => int 1280000 public 'content_type' => string 'video/mp4' (length=9) public 'url' => string 'https://video.twimg.com/ext_tw_video/560049056895209473/pu/vid/720x720/s7f4bf2wkr2txcpa.mp4' (length=91) 3 => object(stdclass)[268] public 'content_type' => string 'application/dash+xml' (length=20) public 'url' => string 'https://video.twimg.com/ext_tw_video/560049056895209473/pu/pl/udxtim8fytsae4hq.mpd' (length=82) 4 => object(stdclass)[269] public 'bitrate' => int 320000 public 'content_type' => string 'video/mp4' (length=9) public 'url' => string 'https://video.twimg.com/ext_tw_video/560049056895209473/pu/vid/240x240/v5jqpunnkaeuvzbx.mp4' (length=91) 5 => object(stdclass)[270] public 'content_type' => string 'application/x-mpegurl' (length=21) public 'url' => string 'https://video.twimg.com/ext_tw_video/560049056895209473/pu/pl/udxtim8fytsae4hq.m3u8' (length=83)
Comments
Post a Comment