0

我想要做的是获取当前在 YouTube 上播放的所有实时视频的列表,然后将它们嵌入,或者如果不可能,至少链接到它们可用的 YouTube。

使用 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

返回空值。

有人能帮我解决这个问题吗?谢谢!

4

1 回答 1

0

Can you var_dump the entire object? It doesn't seem like a PHP problem, but a Zend Framework specific problem. (also, putting a zend-framework tag should lend better results for your question)

于 2012-09-15T02:28:39.747 回答