Reputation: 33
I am using the following url for sending an app generated request to a user:
https://graph.facebook.com/apprequests/?ids=".$userid."&message=Hello&access_token=".$appToken."&method=post
This works fine if the $userid is set as current logged in user. But I am not able to send a request to my friend who is an app user and the above code throws the following error:
{"error":{"message":"(#2) Failed to create any app request","type":"OAuthException","code":2}}
Upvotes: 1
Views: 2184
Reputation: 100205
This worked for me:
$app_id = YOUR_APP_ID; $app_secret = YOUR_APP_SECRET; $token_url = "https://graph.facebook.com/oauth/access_token?" . "client_id=" . $app_id . "&client_secret=" . $app_secret . "&grant_type=client_credentials"; //your app access token $app_access_token = file_get_contents($token_url); $apprequest_url ="https://graph.facebook.com/" . $your_friend_id . "/apprequests?message='some message'&" . $app_access_token . "&method=post"; $result = file_get_contents($apprequest_url); echo $result;
Hope it helps
Upvotes: 2