我試圖通過Ajax HTTP DELETE請求刪除權限,但我回來的響應不是圖形api文檔說我應該得到的。它說我應該得到一個布爾響應(「如果刪除成功則返回true,否則返回錯誤。」)。而是我越來越權限列表的整個對象:Facebook Open Graph - 發出HTTP DELETE請求
var revokePermission = function(permName) {
var revoke_perm_url = "https://graph.facebook.com/me/permissions" +
"?access_token=" + access_token + "&callback=?";
$.ajax({
type: "DELETE",
dataType: "jsonp",
url: revoke_perm_url,
data: {'permission': permName},
success: function(response){
console.log(response);
}
});
}
revokePermission(permission_name);
這裏是我得到的結果:
data: Array[1]
0: Object
bookmarked: 1
create_note: 1
email: 1
installed: 1
photo_upload: 1
publish_actions: 1
publish_stream: 1
read_stream: 1
share_item: 1
status_update: 1
user_interests: 1
user_likes: 1
user_status: 1
video_upload: 1
請注意,API文檔說:
You can de-authorize an application entirely, or just revoke a specific permission on behalf of a user by issuing an HTTP DELETE to PROFILE_ID/permissions or PROFILE_ID/permissions/PERMISSION_NAME respectively. This request must be made with a value user access_token for the current app.
我瞭解所有這些,所以當我向特定權限網址(即「/ permissions/user_likes /」)或通過ajax數據參數發送的權限向基礎權限url發出請求時,它們都返回所有對象我目前的權限以及我請求刪除的權限仍未改變。
然而,當我在設置URL和數據都允許發送,它會返回一個錯誤的對象:
Object
error: Object
code: 2500
message: "Cannot specify permission in both the path and query parameter."
type: "OAuthException"
任何人都知道是怎麼回事?請注意,auth.revokeExtendedPermission的LEGACY REST方法確實可以工作(http://developers.facebook.com/docs/reference/rest/auth.revokeExtendedPermission/)。它返回一個布爾響應,並刪除相應的權限。
解決方案?
感謝Andreyul。不知道爲什麼Ajax'type'參數沒有發送。僅供參考,我還需要在圖表網址上添加「&method = delete」。再次感謝! – chuuke