List of user ids from requests dialog | Migrating from fb:request-form to fb.ui apprequests | Facebook API | JavaScript | PHP

So the facebook requests dialog is not very well documented. It assumes you know how to do a
few things in the documentation. For instance, the "GET /ID/" listed actually means in PHP:

$result = $facebook->api('/'.$requestID.'/');

Here is the original documentation to better help you understand this article:

[http://developers.facebook.com/docs/reference/dialogs/requests/](http://developers.facebook.com/docs/reference/dialogs/requests/)
So if we are migrating from the old fb:request-form to the FB.ui requests dialog the behavior is going to be different. Notably there will be no user IDs of the recipients of the requests returned in the action url. The old FBML would return a bunch of indexes of users who received the request and the requests dialogue returns a list of request IDs with special data attached to each ID. For reference the deprecated FBML looked like this (scroll down):

and then I could extract all the user IDs in PHP like this:

$sentToUsersArray = array ();
if (isset ( $_REQUEST ['ids'] )) {
$sentToUsersArray = $_REQUEST ['ids'];
}

Yuck!

So now we use the FB.ui and ajax to call up the requests dialog
then the callback onInviteFriend is called and you can get the request objects by their ids which are returned in a list in the response object response.request_ids
Then we send the request id list to the PHP script which requires the Facebook PHP API and cURL installed.

Pass the comma delimitate string into $sentRequestsStr and it will return a comma delimited string of the user IDs.


A more eloquent solution at the cost of an extra step. Ahh sigh oh well. Here is how $result is structured so that you can get other data out of the request object.
 
Array (
[id] = > 101501913919285
[application] = > Array
(
[name] = > appname
[id] = > 145161830442
)
[to] = > Array
(
[name] = > Recieving User Name
[id] = > 639139284
)
[from] = > Array
(
[name] = > Sent From User Name
[id] = > 16037411
)
[data] = > gameID=96
[message] = > I thought you would dig this app!
[created_time] = > 2011-05-25T04:43:26+0000
)


comments powered by Disqus