我正在解决一个问题。我想将访问我网站的任何人添加到 Facebook 上的封闭群组中。为此,我创建了一个应用程序并请求权限,但即使在显示状态 = 连接后,该应用程序也不会邀请用户并返回 #3 OAuthException。我仅使用 javascript SDK 执行此操作。
这是我按照此 link 创建的 javascript 代码文件的片段。 .
(function(d) {
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return; }
js = d.createElement('script');
js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
window.fbAsyncInit = function() {
FB.init({
appId : 'APP_ID',
status : true,
xfbml : true
});
FB.login(function(response) {
var accessToken = response.authResponse.accessToken;
FB.api('/GROUP_ID/members'+response.authResponse.userID, 'post', {"access_token": accessToken}, function(response) {
console.log(response);
});
}, {scope: 'user_groups,friends_groups'});
由于你们将我的答案标记为重复,我正在从这里编辑我的问题。如果你们确定无法邀请用户加入群组,请至少确认这一点。我已经访问了提到的那个链接。它说邀请用户加入群组是不可能的,但根据 developer's document据说:-
Applications can invite users to a group by issuing a POST request to /GROUP_ID/members/USER_ID with an app access_token.
Note that user being invited must be a user of the application. The user will be sent a notification saying that they have been invited to the group. The notification will take them to the group page.
如果您对此有任何想法,请回复。 非常感谢。
最佳答案
App and Game Groups is currently in Beta
引用:https://developers.facebook.com/docs/reference/api/app-game-groups/
- 用户必须已获得邀请应用的授权。
- 邀请必须使用应用程序访问 token 。
应用程序可以通过使用应用程序 access_token 向/GROUP_ID/members/USER_ID 发出 POST 请求来邀请用户加入群组。
Note that user being invited must be a user of the application. The user will be sent a notification saying that they have been invited to the group. The notification will take them to the group page. Users can only be invited once. Subsequent invites will fail.
关于jquery - 如何使用 facebook api 邀请经过授权的 facebook 用户应用程序和游戏组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20448083/