2016-09-02 5 views
0

getメソッドを使用してデータをログすると、このエラーが表示されます。私はyoutube v3 APIを使いました。 APIキーを何度も生成しますが、うまくいきません。Youtube API jQueryエラー

{ 
"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); 
    } 
); 

答えて

0

まずあなたのようにあなたのリクエストで詳細を指定することができますので、私は、$はを取得するよりも、より良い$アヤックスを使用することをお勧めいたしますでしょうヘッダ、タイプなど 第2に、おそらく問題のデータタイプは、jsonphttps://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); 
      } 
     }); 

希望します。

+0

ありがとうございました。 –