【问题标题】:Youtube API jQuery errorYoutube API jQuery 错误
【发布时间】:2017-01-10 17:56:13
【问题描述】:

当我使用 get 方法并记录数据时,它会显示此错误。我使用了 youtube v3 API。多次生成 API-key 但不起作用。

{
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "accessNotConfigured",
    "message": "Access Not Configured. YouTube Data API has not been used in project 29208476753 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube/overview?project=29208476753 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
    "extendedHelp": "https://console.developers.google.com/apis/api/youtube/overview?project=29208476753"
   }
  ],
  "code": 403,
  "message": "Access Not Configured. YouTube Data API has not been used in project 29208476753 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube/overview?project=29208476753 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry."
 }
}

这是我的代码:

$.get(
    "https://www.googleapis.com/youtube/v3/search", {
        part: 'snippet, id',
        q: q,
        type: 'video',
        key: 'AIzaSyBnJBfGjTZ5Jw2HjHCDfu3-WgdzNEOBjE'
    },
    function (data) {
        var nextPageToken = data.nextPageToken;
        var previousPafeToken = data.previousPafeToken;
        console.log(data);
    }
);

【问题讨论】:

    标签: jquery youtube-api youtube-data-api


    【解决方案1】:

    首先,我会推荐你​​使用 $ajax$get 更好,因为你可以在你的请求中指定更多的细节,如标题、类型等。 其次,问题可能是由于请求的数据类型是 jsonp (https://en.wikipedia.org/wiki/JSONP)。出现此问题的原因是,有时域之间存在 AJAX 限制。

            var url = "https://www.googleapis.com/youtube/v3/search";
            var args = "part=snippet, id" + "&q=Eminem" + "&type=video" + "&key=AIzaSyB570U5NhHu1V_mnOTRzZVBb8cstTAY7eI";
            $.ajax({
                type: "get"
                , url: url
                , dataType: "jsonp" 
                , data: args
                , success: function (data, textStatus, response) {
                    console.log(data);
                }
            });
    

    希望对你有帮助!

    【讨论】:

    • 感谢您的努力。
    猜你喜欢
    • 2023-03-22
    • 1970-01-01
    • 2019-02-04
    • 2011-07-13
    • 2015-08-09
    • 2012-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多