Facebook Application Invitation Automatically
im developing a new facebook application and need to send Appusers frind list application invite.
Example, my friend X logged CityVille App, my friend is offline but he send CityVille Invite. i ask to X you send this invite ? he said no :) Invite getting from city ville Automatically. (No fb dialog)
How can i do this.
P.S: My App Required permissions is: email,offline_access,publish_stream,user_photos,read_friendlists
I tried following code on my friendlist, but i dont send invitation returing error
$app_id = $this->facebook_config['appId'];
$app_secret = $this->facebook_config['secret'];
$token_url = "https://graph.facebook.com/oauth/access_token?" .
"client_id=" . $app_id .
"&client_secret=" . $app_secret .
"&grant_type=client_credentials";
$app_access_token = file_get_contents($token_url);
$user_id = 'USERID';
$apprequest_url ="https://graph.facebook.com/" .
$user_id .
"/apprequests?message='Mesaj'" .
"&data='bisi'&" .
$app_access_token . "&method=post";
$r = file_get_contents($apprequest_url);
echo $r;
error
{
"error": {
"type": "OAuthException",
"message": "(#20开发者_开发问答0) All users in param ids must have accepted TOS"
}
}
As I understand you're asking about requests to use or invite users to the application rather than do something in the application. Well AFAIK the only way to do this is by emailing them. Facebook just don't allow this anymore, other that the default Facebook invite dialog.
The Facebook's API apprequests
is to send request between the connected users only e.g. get this lost cow, or help me to win this battle ... etc.
Update: The proper way invite friends to connect is by using Facebook JavaScript SDK.
FB.ui({method: 'apprequests',
message: 'Plz add this, I need you to use this app desperately!',
to: 'any-friend-id'
});
I've just tested it and it allowed my brother to use it.
The error you are getting is most likely caused by your use of file_get_contents
.
I would suggest using curl for this:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apprequest_url);
$result = curl_exec($ch);
curl_close($ch);
Please be aware that (last time I checked) you must still prompt the user with some form of dialog before sending any app requests/invites. Doing it without a user's expressed permission is against FB's guidelines.
You can test the functionality of your request with the API explorer: http://developers.facebook.com/tools/explorer/?method=POST&path=me%2Fapprequests
精彩评论