I am using the new FB.ui to create an request to friends on Facebook for my application.
The user is show a panel with their friends and they select the ones they want to send the request.
On the callback I can access the request_id and now I want to get the details for the users that were invited.
If I paste the following code in the browser I can get the user_id of the invited user which is the info I want:
https://graph.facebook.com/138744992885393?access_token=193078857407882|d0048a9beb58a9a247c6b987.0-751640040|zNmBLfZxBBKikoj8RlZiHfKpugM
What I want to be able to do is do the same thing but from my code and then access the information returned.
Here is my code:
function sendRequests() {
FB.ui({
method: 'apprequests',
message: ' should learn more about this awesome site.',
data: 'extra data'
}, function(response) {
if (response != null && response.request_ids && response.request_ids.length > 0) {
for (var i = 0; i < response.request_ids.length; i++) {
alert("Invited: " + response.request_ids[i]);
// somehow send a request to Facebook api to get the invited user id from the request_id and save to the database
//can save these id's in the database to be used to track the user to the correct page in application.
}
top.location.href="http://localhost:3000/";
} else {
alert('No invitations sent');
}
});
}
How can I do this?
I am using Rails 3.0.7 Ruby 1.9.2
You can get the facebook user ID as follows:
Thanks very much to this post on stackoverflow