在 Json 中获取 youtube trends v3 country wise?

Get youtube trends v3 country wise in Json?

如何在 Json.[=13= 中获得 最流行 最多人观看 的 YouTube 趋势]

以前使用 youtube feeds v2。好像弃用了 https://gdata.youtube.com/feeds/api/standardfeeds/IN/most_popular?v=2

我可以获取 youtube api v3 或趋势仪表板等任何其他结果吗? https://www.youtube.com/trendsdashboard

根据 YouTube 准则,YouTube Feeds v2, is now deprecated. You should work with YouTube Data API v3

最受欢迎的视频:

https://www.googleapis.com/youtube/v3/videos?part=contentDetails&chart=mostPopular&regionCode=IN&maxResults=25&key=API_KEY

  1. 部分:

    • 您可以在参数值中包含的部分名称是:
      • id, snippet, contentDetails, fileDetails, liveStreamingDetails, localizations, player, processingDetails, recordingDetails, statistics, status, suggestions, and topicDetails
  2. 图表:

    • 图表参数标识您要检索的图表 (string)
      • 示例mostPopular
  3. 地区代码:

    • 参数值为 ISO 3166-1 alpha-2 国家代码 (string)
  4. :

  5. maxResults : 默认值 5 ,

Read More

var maxVideos = 5;
   $(document).ready(function(){
  $.get(
    "https://www.googleapis.com/youtube/v3/videos",{
      part: 'snippet',
      chart: 'mostPopular',
      kind: 'youtube#videoListResponse',
      maxResults: maxVideos,
      regionCode: 'IN',
      key: 'Your_KEY_Here'},
      function(data){
        var output;
        $.each(data.items, function(i, item){
          console.log(item);
          videTitle = item.snippet.title;
                description = item.snippet.description;
                thumb = item.snippet.thumbnails.high.url;
                channelTitle = item.snippet.channelTitle;
                videoDate = item.snippet.publishedAt;
                Catagoryid = item.snippet.categoryId;
                cID = item.snippet.channelId;
          output = '<div class="maindiv"><div>' +
                        '<a data-fancybox-type="iframe" class="fancyboxIframe" href="watch.php?v=' + vidId + '" target="_blank" ><img src="' + thumb + '" class="img-responsive thumbnail" ></a>' +
                        '</div>' +
                        '<div class="input-group col-md-6">' +
                            '<h3 class="Vtitle"><a data-fancybox-type="iframe" class="fancyboxIframe" href="watch.php?v=' + vidId + '" target="_blank">' + videTitle + '</a></h3>'+
                        '</div><div  id="cTitle"><a href="https://www.youtube.com/channel/'+cID+'" target="_blank">'+channelTitle+'</a></div></div>' +
                    '<div class="clearfix"></div>';
          $('#trending').append(output);
        })

      }
    );
}); 

将文件另存为 .js

并在 HTML 文件中通过 id="trending"

制作 divul

喜欢:

<div id="catagoryname"><h1>Trending</h1></div>
      <ul id="trending"></ul>

检查你的输出。

  • 备注 不要忘记替换您的 API KEY