我试图通过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