在Json获得youtube趋势v3国家明智?

时间:2015-05-27 07:01:06

标签: youtube-api youtube-data-api

如何在Json中按国家/地区获取最受欢迎查看次数最多的YouTube趋势。

以前使用youtube Feed v2。它似乎已被弃用, https://gdata.youtube.com/feeds/api/standardfeeds/IN/most_popular?v=2

我可以获取youtube api v3或趋势信息中心等任何其他结果, https://www.youtube.com/trendsdashboard

2 个答案:

答案 0 :(得分:32)

根据YouTube指南,YouTube Feeds v2现已弃用。您应该使用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. <强> regionCode

    • 参数值为 ISO 3166-1 alpha-2 国家/地区代码(字符串
  4. <强>键

  5. maxResults :默认值5,

  6. Read More

答案 1 :(得分:1)

x = LeftOrRight("abc", 2)

将文件另存为Function LeftOrRight(str As Variant, len As Long) As Variant 'Uncomment this line for Left LeftOrRight = Left(str, len) 'Uncomment this line for Right LeftOrRight = Right(str, len) End Function

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); }) } ); }); 文件中.jsHTML div

像:

ul

检查你的出局。

  • 注 不要忘记替换id="trending"