gpt4 book ai didi

php - 如何通过YouTube API检索视频中的喜欢和不喜欢的东西

转载 作者:行者123 更新时间:2023-12-03 05:55:36 24 4
gpt4 key购买 nike

如何获得每个视频的喜欢和喜欢?我在文档中找不到

$youtube = new Google_Service_YouTube($client);

$searchResponse = $youtube->search->listSearch('id,snippet', array(
'type' => 'video',
'channelId' => 'UCCQeAYn0EfUNp2-RpJKbG5Q'
));


foreach($searchResponse['items'] as $result) {
$videoID = $result['modelData']['id']['videoId'];
$thumb = $result['modelData']['snippet']['thumbnails']['high']['url'];
$title = $result['modelData']['snippet']['title'];
$description = $result['modelData']['snippet']['description'];
// likes
}

最佳答案

Search: list仅返回您正在搜索的视频的列表。要获取有关该视频的其他信息,您需要继续。
通过添加part=statistics,您可以请求Videos: list视频的统计信息。

请求:

https://www.googleapis.com/youtube/v3/videos?part=statistics&id=dQw4w9WgXcQ&key=yourkey

响应:
{
"kind": "youtube#videoListResponse",
"etag": "\"uQc-MPTsstrHkQcRXL3IWLmeNsM/8SpkSG4HF2m1G_UwLNJSMOMb1ws\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#video",
"etag": "\"uQc-MPTsstrHkQcRXL3IWLmeNsM/OZ6HKyY4VjtP3NjwRxAIOM14bts\"",
"id": "dQw4w9WgXcQ",
"statistics": {
"viewCount": "293285349",
"likeCount": "1803097",
"dislikeCount": "87376",
"favoriteCount": "0",
"commentCount": "413069"
}
}
]
}

抱歉,我不是PHP开发人员,所以不能为他提供太多帮助。

关于php - 如何通过YouTube API检索视频中的喜欢和不喜欢的东西,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42808162/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com