调用blogger API时访问未配置错误

时间:2014-09-17 00:32:08

标签: jquery ajax json blogger

我正在尝试使用jQuery和JSON获取博客详细信息。我还设置了一个API密钥(用于浏览器应用程序)来访问博客,但我的API密钥无法正常工作。请建议如何正确配置它。

代码:

<!Doctype html>
        <html>
        <head>
        <title>My Page</title> 

            <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>

        </head>
        <body>
        <script>

        var url =  'https://www.googleapis.com/blogger/v2/blogs/',
            apikey = '/posts?key=API_KEY',
            blogId = '4011997376355783864';


            $.ajax({

                url: url +blogId+apikey,

                dataType: "jsonp",

                success  : function(data){

                    console.log(data);
                },
                error   :function(request, error){
                    alert('error');
                }

            });


        </script>
        </body>
        </html>

错误:

error: Objectcode: 403
errors: Array[1]
message: "Access Not Configured. Please use Google Developers Console to activate the API for your project."

主要细节:

API Details

1 个答案:

答案 0 :(得分:0)

我正在开发一个Android应用程序,我希望与一些Blogger&#39;博客,当然,我需要访问Blogger API v3。我在请求中遇到了同样的错误:

{
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "accessNotConfigured",
    "message": "Access Not Configured. The API is not enabled for your project, or there is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your configuration.",
    "extendedHelp": "https://console.developers.google.com"
   }
  ],
  "code": 403,
  "message": "Access Not Configured. The API is not enabled for your project, or there is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your configuration."
 }
}

我已经为应用程序创建了一个API密钥( Android密钥),我认为我正在以正确的方式进行操作但每次尝试时都会出现错误,直到我创建了另一个API密钥类型(服务器密钥或浏览器密钥)并且发生了魔法。

直到现在我才明白逻辑,但我认真地认为这样的事情可以在官方文档中描述。