我正在尝试获取按观看次数最多的视频排序的视频列表。我一直在尝试以下代码,但它没有返回任何响应。
var request = gapi.client.youtube.search.list({
part: 'snippet,contentDetails,statistics',
q: query,
maxResults: count,
order:'viewCount'
});
request.execute(onSearchResponse);
上面的代码没有返回任何响应。有人可以将我重定向到正确的方向吗?我已经查看了文档。
https://developers.google.com/youtube/v3/docs/search/list
最佳答案
使用 YouTube API v3(并修改此 answer 中提供的参数),您可以使用此请求 URL 获取观看次数最多的 YouTube 视频。
https://www.googleapis.com/youtube/v3/search?key=<YOUR_API_KEY>&part=snippet&order=viewcount&maxResults=1
以下信息取自 YouTube Data API - official documentation :
snippet
. viewcount
. 1 链接文档说
order
中只允许使用这些值。范围:关于javascript - 如何使用 javascript API 获取观看次数最多的 youtube 视频?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53248545/