【发布时间】:2018-11-25 17:07:38
【问题描述】:
我遇到了创建分页电影列表的问题。
下面是我的代码:
$API_key = 'my_api_key';
$channelID = 'channel_id';
$maxResults = 15;
$videoList = json_decode(file_get_contents('https://www.googleapis.com/youtube/v3/search?order=date&part=snippet&channelId='.$channelID.'&maxResults='.$maxResults.'&key='.$API_key.''));
foreach($videoList->items as $item){
if(isset($item->id->videoId)){
echo '<div class="youtube-video col-xl-4">
<iframe width="100%" height="100%" src="https://www.youtube.com/embed/'.$item->id->videoId.'" frameborder="0" allowfullscreen></iframe>
<h3>'. $item->snippet->title .'</h3>
</div>';
}
}
我缺少什么,接下来我应该做什么?我正在阅读有关 pageToken 的信息,但我不知道如何获取它的价值以使其正常工作。
【问题讨论】:
标签: php youtube-data-api