【发布时间】:2013-12-22 08:21:39
【问题描述】:
所以我有一个函数可以从 ZEND Gdata API 检索所有播放列表条目。 现在,我只是尝试添加“getNextFeed()”,但 V3 使用“pageToken”来显示下一个条目。 我遇到的问题是如何在我的代码中检索“nextPage”并实现它。 我知道逻辑是获取'nextPageToken'并将其放入循环中,但我不知道如何。 抱歉,我是 JSON 新手。
<?php
$client = new Google_Client();
$client->setDeveloperKey($DEVELOPER_KEY);
$youtube = new Google_YoutubeService($client);
try {
$searchResponse = $youtube->playlistItems->listPlaylistItems('id,snippet', array(
'playlistId' => $_GET['q'],
'maxResults' => $_GET['maxResults']
));
foreach ($searchResponse['items'] as $searchResult) {
$videoId = $searchResult['snippet']['resourceId']['videoId'];
$videoTitle = $searchResult['snippet']['title'];
$videoThumb = $searchResult['snippet']['thumbnails']['high']['url'];
$videoDesc = $searchResult['snippet']['description'];
print '<div>'.
$videoTitle.'<br/><br/><img src="'.
$videoThumb.'" /><br/>'.
$videoId.'<br/>'.
$videoDesc.'<br/>'.
'</div><br/><br/>';
}
} catch (Google_ServiceException $e) {
return;
} catch (Google_Exception $e) {
return;
}
}
?>
【问题讨论】:
标签: php youtube-api