Reputation: 2261
I've created a simple facebook app that allows users to login with their facebook account. Once they log in they are then invited to the exclusive app group using the graph api method below:
POST /{group-id}/members
member: {member-id}
It works great when the member being added is a user in a development/tester role, but if they aren't I get the following:
{
"error": {
"message": "(#4002) The attempt to invite the user to the group failed.",
"type": "OAuthException",
"code": 4002
}
}
What permissions am I missing that prevent me from being able to add app users to this app group?
I thought I might need the user_groups
permission, but I don't need to get their groups and the Graph API documentation says that apps can use an app access token to add users to app groups...
SOLUTION
@Cbroe was correct. Here is the code that I had to use to display the join dialog for users to join the group:
FB.ui({
method: 'game_group_join',
id: '123',
display:'popup'
}, function(res){
console.log(res);
if(res.added == true){
alert('joined group')
} else {
alert('error: '+res.error_message)
}
});
Upvotes: 1
Views: 698
Reputation: 96383
https://developers.facebook.com/docs/graph-api/reference/v2.2/group/members#publish says,
“Apps can invite people (if they are an admin, developer, or tester of the app) to a group created by that app […]”
– I think that means inviting only works that way for people that have a “role” in the app.
For normal users, you will have to show them the Join dialog, as described here: https://developers.facebook.com/docs/games/app-game-groups/#add_user
It is then up to the user to decide there and then whether they want to join or not.
That same document also says,
“You should use in-game messaging to communicate invites and may consider using App Notifications or Requests to tell the player about outstanding requests.”
Upvotes: 1