0

I'm making a facebook app which will show a user's friends, then the user will choose a friend and the app will send that friend an apprequest with PHP. With that apprequest I also will send the user's id, so that when the receiver plays the app, I will know that it will be thanks to that user.

To get a user's friends I'm using the following code

$friends_array = $facebook->api('/me/friends');

(I know this will only return a user's friends who have already accepted the app's permissions, so I'm using 2 test accounts which are friends)

To send the apprequest

If I use the following

$param = array(
'message'      => 'Check out the latest update',
'data'         => 'some_data_string',
"to" => $_POST["friend_id"],
"method" => "POST",
'access_token' => $facebook->getAccessToken(),
);
$tmp = $facebook->api("/me/apprequests", "POST", $param);

It is executed, but nothing is received.

If I use the following

$param = array(
'message'      => 'Check out the latest update',
'data'         => 'some_data_string',
'access_token' => $facebook->getAccessToken(),
);
$tmp = $facebook->api("/".$_POST["friend_id"]."/apprequests", "POST", $param);

I get the following error "Fatal error: Uncaught OAuthException: (#2) Failed to create any app request thrown ..."

The app is public and available to all users.

Do I need maybe to submit the app for any special permissions in order to post an apprequest?

Also if you have any other suggestion to have the desired results I'm referring to at the beginning, please reply.

0 Answers0