2012-09-15 3 views
0

내가하고 싶은 일은 현재 YouTube에서 재생중인 모든 라이브 동영상 목록을 가져 오는 것입니다.PHP - YouTube 라이브 API - 동영상 ID 가져 오기

Zend 프레임 워크를 사용하여 피드를 검색하는 코드는 매우 간단합니다.

$videoFeed = $yt->getVideoFeed('https://gdata.youtube.com/feeds/api/charts/live/events/live_now'); 
    foreach ($videoFeed as $videoEntry) { 
     printVideoEntry($videoEntry); 
    } 

그리고 printVideoEntry()는 해당 비디오에 관한 많은 데이터를 표시합니다. 채널 또는 재생 목록 피드에서 작동합니다. 실시간 스트림에 사용될 때 많은 데이터가 없습니다. 그것은 단지 제목, 설명 및 저자 일뿐입니다. 내가 원하는 것은 비디오의 비디오 ID입니다.

피드의 URL을 요청하면 피드 xml이 표시됩니다. 다음은 비디오 항목의 한 예입니다.

<entry gd:etag='W/&quot;CUYEQ347eCp7I2A9WhJUFks.&quot;'> 
<id>tag:youtube.com,2008:live:event:IKv8FeyLmiIl-8iUVVahpRaYMLRCD0xt</id> 
<published>2012-09-14T21:14:31.000Z</published> 
<updated>2012-09-14T22:51:42.000Z</updated> 
<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#liveEvent'/> 
<title>TGIFF Live Stream with Realm (League of Legends)</title> 
<summary>Realm's Livestream: Thank God it's Freakin Friday! This week we're getting into some League of Legends action and teaching our ambitious Hundar how to play! This live show will air every Friday from 4-6pm PST on http://www.machinimalive.com 
Subscribe to the Machinima Live newsletter here! http://eepurl.com/o1-kP</summary> 

<content type='application/atom+xml' src='https://gdata.youtube.com/feeds/api/users/MachinimaRealm/live/videos/YbeDQJ_FSVA?v=2'/> 
<link rel='self' type='application/atom+xml' href='https://gdata.youtube.com/feeds/api/users/VEbcFWM43PS-d5vaSKUMng/live/events/IKv8FeyLmiIl-8iUVVahpRaYMLRCD0xt?v=2'/> 
<author><name>MachinimaRealm</name><uri>https://gdata.youtube.com/feeds/api/users/MachinimaRealm</uri><yt:userId>VEbcFWM43PS-d5vaSKUMng</yt:userId></author> 

<media:group><media:description type='plain'>Realm's Livestream: Thank God it's Freakin Friday! This week we're getting into some League of Legends action and teaching our ambitious Hundar how to play! This live show will air every Friday from 4-6pm PST on http://www.machinimalive.com 
Subscribe to the Machinima Live newsletter here! http://eepurl.com/o1-kP</media:description><media:title type='plain'>TGIFF Live Stream with Realm (League of Legends)</media:title></media:group><yt:status>active</yt:status><yt:when end='2012-09-15T01:00:00.000Z' start='2012-09-14T22:51:42.000Z'/></entry> 

'콘텐츠'항목에 동영상 ID가 'src'로 포함되어 있지만 액세스 방법을 모르겠습니다.

echo $videoEntry->content->src 

을 반환합니다.

누군가 나를 도와 줄 수 있습니까? 감사!

답변

0

var_dump 전체 개체를 사용할 수 있습니까? 그것은 PHP 문제처럼 보이지는 않지만 Zend Framework 특정 문제입니다. (또한 zend-framework 태그를 추가하면 더 나은 결과를 얻을 수 있습니다.)

+0

var_dumping을 사용하면 객체가 Zend에서 많은 양의 데이터를 생성하지만 탐색하기가 어려워집니다. (Zend_Gdata_YouTube_VideoEntry) # 30 (38) {[ "_entryClassName : protected" NULL "[_ _ : _ 보호 : 보호"] => NULL [ "_comments : 보호"] => NULL [ "_feedLink : 보호 된"] => NULL [ NULL] [ "_location : protected"] => NULL 원하는 데이터가 거기에 중첩되어 있습니다. –

관련 문제