【问题标题】:gdata link from Firefox doesn't work any more for YouTube API?来自 Firefox 的 gdata 链接不再适用于 YouTube API?
【发布时间】:2015-09-01 12:08:11
【问题描述】:

至少一年前,如果我去

http://gdata.youtube.com/feeds/api/videos?v=2&max-results=1&q=intitle:"Relapse"+intitle:"Eminem"&orderby=viewCount

从 FireFox 浏览器,我可以在此地址中找到符合搜索查询的视频标题列表。

但是现在不行了。

它被弃用了吗?

【问题讨论】:

    标签: youtube-api


    【解决方案1】:

    @user3123767 YouTube 数据 API (v2) 已于 2014 年 3 月 4 日正式弃用。有关更多信息,请参阅我们的弃用政策。请使用 YouTube 数据 API (v3) 进行新的集成,并将仍然使用 v2 API 的应用程序也迁移到 v3 API。 Ref

    现在所有对 Google API 的调用都要求您发送您的 Api 密钥,您可以从 Here 获得一个

    获得 API 密钥后,您可以进行各种调用

    例如使用关键字“好莱坞”搜索视频 运行此代码并在控制台中查看结果

    (function($){
    function SearchYouTube(queryToSearch,pageToken,ApiKey,maxResults){
    var 
    YoutubeUrl="https://www.googleapis.com/youtube/v3/", 
    pageToken=pageToken,
    maxResults=maxResults,
    ApiKey=ApiKey,
    $.get(YoutubeUrl+"search?q="+queryToSearch,{
       part : 'snippet',
       pageToken:pageToken,
       key:ApiKey,
       maxResults:maxResults
       },
       function(data) {
    
    //let check if request is granted with our Api Key   
       if(!data.items[0]){console.log("System Configuration Error");}
       //If request granted okay 
       var 
       videoId=data.items[0].id.videoId,
       videoImgUrl=data.items[0].snippet.thumbnails.high.url,//medium | default | high
       videoTile=data.items[0].snippet.title,
       nextPageToken=data.items[0].nextPageToken;// Useful if you want the next set of datas
       //Display data on page here if you want
       //See console Log of results that you can use
        console.log(data);//Dump data
    
       }//Success 
       );
    }
    //Usage
    SearchYouTube("Hollywood","","xxx Your Api Key xxx",5);
    //==================All Closed==========  
    })(jQuery);
    

    查看工作示例 Here

    【讨论】:

      【解决方案2】:

      可能有几个原因。

      YouTube API v2.0 is deprecated 不确定它现在是否完全关闭。

      我认为现在所有对 Google API 的调用都要求您至少发送一个public API key。我刚刚测试了以下

      http://gdata.youtube.com/feeds/api/videos?q=skateboarding+dog&start-index=21&max-results=10&v=2&key=[api 键]

      它返回了

      此网页不可用

      我想我不得不说它不再工作了,你应该尝试改用 YouTube API v3。

      【讨论】:

        猜你喜欢
        • 2012-04-25
        • 2014-02-09
        • 2011-11-12
        • 1970-01-01
        • 2014-05-13
        • 2015-03-24
        • 2013-03-17
        • 2014-04-01
        • 1970-01-01
        相关资源
        最近更新 更多