gpt4 book ai didi

node.js - 无法在 Facebook Graph API 上使用/apprequests 端点

转载 作者:太空宇宙 更新时间:2023-11-04 02:20:25 25 4
gpt4 key购买 nike

我在 Node 上使用passport.js 来验证用户身份。我正在尝试添加用户邀请 friend 加入我的游戏的功能。我可以查询/invitable_friends 端点来获取未使用该应用程序的 friend 列表,但我似乎无法让/apprequests 工作。

我正在尝试根据 API reference 从浏览器发出发布请求.

var url = 'https://graph.facebook.com/'+ uid + '/apprequests' +
'?access_token=' + accessToken +
'&message=Invitation' +
'&action_type=INVITE' +
'&ids=' + inviteTokens;

其中,invitableTokens 是从/invitable_friends 返回的邀请 token 的逗号分隔字符串。

我收到此错误:

{
"error": {
"message": "Invalid token: \"811513274\". An ID has already been specified.",
"type": "OAuthException",
"code": 2500,
"fbtrace_id": "BrulDCVO+SE"
}
}

如果我排除 ids 参数,查询就会工作,但请求只是发送给我自己。如果我在端点路径中排除我的 uid,则会收到错误:

{
"error": {
"message": "(#803) Some of the aliases you requested do not exist: {inviteTokens},
"type": "OAuthException",
"code": 803,
"fbtrace_id": "AL6Yo+jAwWW"
}
}

这意味着端点正在期待其他东西,但文档使用 example 中的访问 token :

FB.ui({method: 'apprequests',
message: 'YOUR_MESSAGE_HERE',
to: 'USER_ID, USER_ID, INVITE_TOKEN'
}, function(response){
console.log(response);
});

我还尝试使用 Graph API 浏览器,得到了相同的结果。

希望我在这里提供了足够的详细信息,但如果您需要其他信息,请告诉我。提前致谢!

最佳答案

因此,Facebook 不允许直接通过 POST 请求发送邀请。邀请必须通过 Javascript SDK 中的前端对话框,因此 FB 可以验证用户是否确实想要发送邀请。

关于node.js - 无法在 Facebook Graph API 上使用/apprequests 端点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33699546/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com