我使用以下代码来获取 YouTube 视频的标题和点赞数:
$gdata_url = 'http://gdata.youtube.com/feeds/api/videos/'.$videoId.'?v=2&alt=jsonc';
$json_content = file_get_contents($gdata_url, 0, null, null);
但目前 json 响应的 title 始终包含 https://youtube.com/devicesupport 而不是实际标题,并且 json 响应不包含 viewCount。
请问您如何解决这个问题吗?
最佳答案
Youtube API v2 has been deprecated 。您可以找到如何使用 v3 here 获取视频信息。
您可以使用 part
参数来定义要检索的属性。 Snippet
为您提供大部分属性,包括标题,而 statistics
返回点赞计数。您可以使用 "snippet,statistics"
通过一次调用即可获取这两项内容。
关于php - 获取标题和 likeCount youtube API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30136690/