2017-08-19 24 views
0

我剛剛開始掌握第三方API的構建,我想添加到我自己的網站(用AngularJS編寫)中的一個功能是構建Blogger的API以創建博客提要。爲什麼我使用Blogger API和AngularJS獲得403錯誤?

我已經設置好一切和我看到了200級的地位的請求,但在網絡選項卡中的響應顯示:

// API callback 
angular.callbacks._0({ 
"error": { 
    "errors": [ 
    { 
    "domain": "usageLimits", 
    "reason": "dailyLimitExceededUnreg", 
    "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.", 
    "extendedHelp": "https://code.google.com/apis/console" 
    } 
    ], 
    "code": 403, 
    "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup." 
} 
} 
); 

這裏是我的控制器:

$http.jsonp('https://www.googleapis.com/blogger/v3/blogs/' + id + '?api_key=' + apiKey).then(function(res) { 
    $scope.blogData = res.data; 
    console.log($scope.blogData, res); 
}, function(error) { 
    console.log(error); 
}); 

所以請求通過事物的外觀成功,但響應顯示身份驗證問題。我已閱讀文檔和博客將公開,所以不應該有任何祕密等問題。

任何想法?

+0

你可以嘗試去到您的谷歌開發者控制檯,看看你是否已經超出了您的每日配額的例子。 –

回答

0

問題是url api_key中的參數。它應該只有key。 像這樣工作。

$http.jsonp('https://www.googleapis.com/blogger/v3/blogs/' + id + '?key=' + apiKey).then(function(res) { 
    ... 
}, function(error) { 
    console.log(error); 
}); 

這裏從文檔https://developers.google.com/blogger/docs/3.0/using#RetrievingABlog

+0

是啊,解決了這個問題 - 在我發佈消息後幾分鐘,注意到了url中的錯誤。 '?api_key ='是錯誤的。感謝您的幫助。 –

相關問題