获取不同的视频ID YouTube



code.google.com针对PHP 的API

我使用了这个函数:函数printVideoEntry($videoEntry)并得到

视频ID:XXXXXXXXXXXXXXXXXXXXXXXXXXXX
观看页面:http://www.youtube.com/watch?v=YYYYYYYYYYYYYY&feature=youtube_gdata_player
Flash Player Url:http://www.youtube.com/v/YYYYYYYYYYYYY?version=3&f=播放列表&app=youtube_gdata

如果我通过给定的视频id,它会给我错误:

未捕获异常"Zend_Gdata_App_HttpException",消息为'预期响应代码200,得到400无效id'

如果我从手表页面传递YYYYYYYYYYYYYY和Flash Player Url(两者都相同),我就会得到我需要的。

非常感谢您的帮助,提前谢谢。

使用此功能获取视频条目

function printVideoEntry($videoEntry) {
  echo "<div onclick="ytvbp.presentVideo('".$videoEntry->getVideoId()."')" >";
  echo 'Video: '.$videoEntry->getVideoTitle() . "<br>";
  echo "</div>";
  echo 'Video ID: ' . $videoEntry->getVideoId() . "<br>";
  echo 'Watch page: ' . $videoEntry->getVideoWatchPageUrl() . "<br>";
  echo 'Flash Player Url: ' . $videoEntry->getFlashPlayerUrl() . "<br>";
} 

我正在调用的打印视频功能

 function getAndPrintPlaylistVideoFeed($playlistListEntry) {
    $yt = new Zend_Gdata_YouTube();
    $playlistVideoFeed =  $yt->getPlaylistVideoFeed($playlistListEntry->getPlaylistVideoFeedUrl());
    foreach ($playlistVideoFeed as $playlistVideoEntry) {
    $getandprintplaylistvideofeed_array[] = printVideoEntry($playlistVideoEntry);
    }

$videoEntry应该是一个VideoEntry-对象,您可以基于ID:获得它

$videoEntry = $yt->getVideoEntry('the0KZLEacs');

然后你可以调用函数并将其设置为参数:

printVideoEntry($videoEntry);

或者您可以编辑printVideoEntry:的第一行

function printVideoEntry($videoId) {
  $videoEntry = $yt->getVideoEntry('the0KZLEacs');
  //...
}

查看文档,了解可以从VideoEntry=)中挤出哪些信息

最新更新