【问题标题】:How to retrive likes and dislikes on a video via the YouTube API如何通过 YouTube API 检索视频的喜欢和不喜欢
【发布时间】:2017-03-15 11:14:21
【问题描述】:

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

$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
}

【问题讨论】:

    标签: php youtube google-api google-api-php-client youtube-data-api


    【解决方案1】:

    Search: list 仅返回您正在搜索的视频列表。要获得有关相关视频的更多信息,您需要前往。 Videos: list 通过添加 part=statistics 您正在请求视频的统计信息。

    请求:

    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 开发人员,所以对他的代码帮助不大。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-04-06
      • 2019-10-28
      • 1970-01-01
      • 2013-04-03
      • 2012-12-28
      • 2020-10-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多