如何为youtube api实现nextpagetoken

时间:2017-09-26 06:32:40

标签: php youtube-api

我尝试了下面的代码:

$api_url = 'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=50&pageToken=CAoQAA&playlistId='.$playlist_id. '&key=' . 
$api_key;

如果你给出一个解决方案我很感激。

1 个答案:

答案 0 :(得分:0)

将nextPageToken放在pageToken参数中。您可以查看此SO post以获取实际代码示例:

   // checking if nextPageToken exist than return our function and 
      // insert $next_page_token with value inside nextPageToken
    if(isset($searchResponse['nextPageToken'])){
          // return to our function and loop again
        return youtube_search($query, $max_results, $searchResponse['nextPageToken']);
    }

另外,请检查this post以获取更多参考资料。