duanqu9279
duanqu9279
2017-04-20 21:47

如何获得热门视频youtube API PHP?

  • php
  • charts
  • youtube-api
已采纳

I try using the chart parameter to get trending videos, but it says that chart is not a valid parameter. I am using PHP. I have the region and category and everything set fine. Is this a bug? How do I do it?

here is the code I have

  $searchResponse = $youtube->search->listSearch('id,snippet', array(
        //'type' => 'video',
        'part' => 'snippet',
          'location' => 'GB',
          'videoCategoryId' => '23',
         'chart' => 'mostPopular',
        'order' => 'date',
        'maxResults' => '50'
    ));

says: An client error occurred: (list) unknown parameter: 'chart'

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • duanmanmian7589 duanmanmian7589 4年前

    You are looking for Videos list endpoint not Search list endpoint, you can get the most popular videos for your regionCode & videoCategoryId with :

    $videosResponse = $youtube->videos->listVideos('snippet', array(
        'chart' => 'mostPopular',
        'maxResults' => 50,
        'regionCode' => 'GB',
        'videoCategoryId' => '23'
    ));
    
    点赞 评论 复制链接分享

为你推荐