Youtube Next Previous 分页 Json
Youtube Next Previous Pagination with Json
我正在从 json 结果中获取 nextPageToken,但仍然无法正常工作。不是没有问题存在,任何人都可以调查这个并纠正并帮助我解决这个问题。
`
$jsonURL = file_get_contents("https://www.googleapis.com/youtube/v3/search?order=date&part=snippet&contentDetail&channelId= {$channelID}&type=video&maxResults=2&key={myAPIKey}");
$result = json_decode($jsonURL, 真);
foreach ($result['items'] 作为 $searchResult) {
$nPt = $result['nextPageToken'];
$Tmburl = $searchResult['snippet']['thumbnails']['high']['url'];
$views = $searchResult['statistics']['viewCount'];
$date = $searchResult['snippet']['publishedAt'];
echo '<h3>'.$searchResult['snippet']['title'].'</h3>';
echo '<img src="'.$Tmburl.'"/>';
echo '<p>'.$searchResult['snippet']['description'].'</p>';
}
// Pagination
echo '<h1><a href="?id='.$channelID.'&pageToken='.$result['nextPageToken'].'">next</a></h1>';
`
下一个 - 上一个分页不起作用。即使我正在获取 nextPageToken 编号,但 link 无法正常工作。
我明白了,只需在 Json URL 中发送 pageToken 值,然后分页工作。
我正在从 json 结果中获取 nextPageToken,但仍然无法正常工作。不是没有问题存在,任何人都可以调查这个并纠正并帮助我解决这个问题。
`
$jsonURL = file_get_contents("https://www.googleapis.com/youtube/v3/search?order=date&part=snippet&contentDetail&channelId= {$channelID}&type=video&maxResults=2&key={myAPIKey}");
$result = json_decode($jsonURL, 真);
foreach ($result['items'] 作为 $searchResult) {
$nPt = $result['nextPageToken'];
$Tmburl = $searchResult['snippet']['thumbnails']['high']['url'];
$views = $searchResult['statistics']['viewCount'];
$date = $searchResult['snippet']['publishedAt'];
echo '<h3>'.$searchResult['snippet']['title'].'</h3>';
echo '<img src="'.$Tmburl.'"/>';
echo '<p>'.$searchResult['snippet']['description'].'</p>';
}
// Pagination
echo '<h1><a href="?id='.$channelID.'&pageToken='.$result['nextPageToken'].'">next</a></h1>';
`
下一个 - 上一个分页不起作用。即使我正在获取 nextPageToken 编号,但 link 无法正常工作。
我明白了,只需在 Json URL 中发送 pageToken 值,然后分页工作。