我已经为此苦苦挣扎了几个小时,我不知道为什么不工作。我需要使用 YouTube API 和 Zend 从 VideoID 获取详细信息,所以我创建了一个这样的函数
function listYoutubeVideo($id) {
$videos = array();
try {
$yt = new Zend_Gdata_YouTube();
$videoFeed = $yt->getVideoEntry($id);
foreach ($videoFeed as $videoEntry) {
$videoThumbnails = $videoEntry->getVideoThumbnails();
$videos[] = array(
'thumbnail' => $videoThumbnails[0]['url'],
'title' => $videoEntry->getVideoTitle(),
'description' => $videoEntry->getVideoDescription(),
'tags' => implode(', ', $videoEntry->getVideoTags()),
'url' => $videoEntry->getVideoWatchPageUrl(),
'flash' => $videoEntry->getFlashPlayerUrl(),
'dura' => $videoEntry->getVideoDuration(),
'id' => $videoEntry->getVideoId()
);
}
} catch (Exception $e) {
}
return $videos;
}
我用数组和函数做它的原因是因为我想缓存函数。
我不知道代码有什么问题,我使用完全相同的代码,只是将 getVideoEntry 更改为其他类型的提要,它可以工作。