2014-09-16 3 views
1

잠시 동안 찾고 있었으니 지금 물어볼 시간입니다. 어떻게 내 커스텀 PHP 피드에서 트위터 비디오를 얻을 수 있습니까? 나는 사진의 URL에 뭔가를 사용하여 문제를 풀 수 없다 ..twitter에서 비디오를 가져 오기 위해 PHP를 사용합니다.

$tweet->entities->media[0]->media_url; 

하지만 사용자를 얻을 수있는 솔루션을 찾을 수없는 너무 좋은 것입니다 비디오에 대한 동영상 URL, 심지어 포스터 이미지 URL을 공급한다.

답변

1

사용 검색 '필터를 = 비디오' 예를 호출 할 수 있습니다 :

?q=#dog&result_type=recent&count=20&filter=videos&include_entities=true 

동영상 URL : HTML

[urls] => Array 
(
    [0] => stdClass Object 
     (
      [url] => https://t.co/u9Yaulk7Nz 
      [expanded_url] => https://vine.co/v/O2T90LHOwV6 
      [display_url] => vine.co/v/O2T90LHOwV6 
      [indices] => Array 
       (
        [0] => 97 
        [1] => 120 
       ) 

     ) 

) 

예 : https://t.co/u9Yaulk7Nz 는 울부 짖는 응답을 참조

<a href="https://vine.co/v/O2T90LHOwV6"><img src="http://pbs.twimg.com/ext_tw_video_thumb/571566115719004160/pu/img/H8GR0a02w_vAzUjr.jpg:thumb"></a> 

도움이 될 것입니다.

2

// Check if tweet has media 
if (!empty($tweet->entities->media)) { 
    $searchArray = array(
     "id" => $tweet->id, // id of the tweet we just fetched 
     "include_entities" => true // tells twitter API to return videos and stuff 
    ); 

    // Get extended_entities 
    $extendedEntities = $connection->get("statuses/show", $searchArray); 
    foreach($extendedEntities->extended_entities->media as $media){ 
     var_dump($media->video_info->variants); 
    } 
} 

예 결과의 당신이 $의 트윗에 저장된 검색/트윗을 사용하여 트윗이 페치 있다고 가정 해 봅시다

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) 
관련 문제