Google Youtube API nextPageToken

时间:2018-02-22 03:18:57

标签: youtube google-api youtube-api

我已经阅读了很多关于将nextPageToken与Youtube API一起使用的帖子。

我正在使用的参考是

https://developers.google.com/apis-explorer/?hl=en_US#p/youtube/v3/youtube.commentThreads.list?part=snippet&maxResults=100&order=time&videoId=xyvQaVUeu90&fields=items(id%252Csnippet%252FtopLevelComment%252Fsnippet%252FtextDisplay)%252CnextPageToken&_h=35&

我使用的视频ID是xyvQaVUeu90

我运行的脚本返回nextPageToken为 QURTSl9pMm1EbHlJZFdJTENzcHpIMGI3VWllOVl0enBxREN3NlZSYzAzZVdQTkNKNV9XQkpmQTNYLWhhVDIzeGN5eUdXUDZqWUJkdFdBOGdKVksyOENUU3B4b014Yi12Y05PdGRRcVlTaHp3VXEyR0JxRFVYMm5rWG1sbUZsRmk

因此,根据API,如果我使用nextPageToken,则应返回下一页评论,但是当我将nextPageToken作为pageToken

参考:

https://developers.google.com/apis-explorer/?hl=en_US#p/youtube/v3/youtube.commentThreads.list?part=snippet&maxResults=100&order=time&pageToken=QURTSl9pMm1EbHlJZFdJTENzcHpIMGI3VWllOVl0enBxREN3NlZSYzAzZVdQTkNKNV9XQkpmQTNYLWhhVDIzeGN5eUdXUDZqWUJkdFdBOGdKVksyOENUU3B4b014Yi12Y05PdGRRcVlTaHp3VXEyR0JxRFVYMm5rWG1sbUZsRmk&videoId=xyvQaVUeu90&fields=items(id%252Csnippet%252FtopLevelComment%252Fsnippet%252FtextDisplay)%252CnextPageToken&_h=36&

它返回:

{
 "error": {
  "errors": [
   {
    "domain": "youtube.parameter",
    "reason": "invalidPageToken",
    "message": "The request specifies an invalid page token.",
    "locationType": "parameter",
    "location": "pageToken"
   }
  ],
  "code": 400,
  "message": "The request specifies an invalid page token."
 }
}

任何帮助都会很好!

1 个答案:

答案 0 :(得分:1)

它完美运作。只需确保在双引号之间复制所有内容("")。我能够毫无问题地使用它。例如,您的链接中提供的nextPageToken

"QURTSl9pMFZuQUJYNGc4dDVZRjRjYlJ3d0M1MlIzeTRSeEJfclZOeEEzdncxRVM4bGZFOXdIRVVVRkJibjBSVW5xaEtBTE1zS0VTd2lDNndrRmJQaG4tY1dScXFral9hMVQ3NmJidFI1Vk83a0xhWEJNU2cwMlYweERGLU1uMDhLazg="

但你只复制了

QURTSl9pMFZuQUJYNGc4dDVZRjRjYlJ3d0M1MlIzeTRSeEJfclZOeEEzdncxRVM4bGZFOXdIRVVVRkJibjBSVW5xaEtBTE1zS0VTd2lDNndrRmJQaG4tY1dScXFral9hMVQ3NmJidFI1Vk83a0xhWEJNU2cwMlYweERGLU1uMDhLazg

您未包含=