FaceBook API: get the request object for the request identifier - log in to the account that sent the request. Using Request Request APIs

I use the "query dialog" to create Facebook queries. To force the user to send requests, I need to access the Request object using the graphical API. I tried most of the permission options that seemed appropriate (read_requests and user_about_me) to get the request object, but instead I get a false response. Am I using the wrong permissions?

I can access the request object using the chart API from the account to which the request was sent.

http://developers.facebook.com/docs/reference/dialogs/requests/

The returned data is a comma separated list created by request_ids. To find out to whom the requests were sent to, you must go through the information for each request object identified by the request identifier.

+6
facebook facebook-graph-api facebook-c # -sdk
source share
5 answers

I asked myself this question a while ago:
How to get all requests sent by me ?

Answer: you cannot !
You have two options:

  • Save the request_id returned when the user submitted the request so that they can subsequently access them and get the data they need.
  • Knowing the receiver!

The proof above, you can check the friend_request table. The indexed field is the uid_to field!

+4
source share

This is if you want him to know iframe mode, since you no longer need iframe mode

 function sendRequest() { FB.ui({ method: 'apprequests', title: 'Invite friends to join you', message: 'Come play with me.' }, function (res) { if (res && res.request_ids) { var requests = res.request_ids.join(','); $.post('FBRequest.ashx', { request_ids: requests }, function (resp) { }); } }); return false; } 
+1
source share

If you want to know the identifiers of the users to whom you just sent a request. Then you need this code:

 var request = { message: msg, method: 'apprequests', title: 'Select some of your friends' }; FB.ui(request, function (data) { if (data && data.request_ids) { // Get the uid of the person(s) who was/were invited var uids = new Array(); FB.api("/?ids=" + data.request_ids.join(), function(data2) { for (i = 0; i<data.request_ids.length; i++) { uids[i] = data2[data.request_ids[i]]['to']['id']; } # do something with uids here }); } }); 
0
source share

I don't know if this helps, but here's how I handle it.

JavaScript:

  function sendRequest() { FB.ui({ display: 'iframe', method: 'apprequests', title: 'Invite friends to join you', message: 'Come play with me.' }, function (res) { if (res && res.request_ids) { var requests = res.request_ids.join(','); $.post('FBRequest.ashx', { request_ids: requests }, function (resp) { }); } }); return false; } 

Server side (FBRequest.ashx):

  // get operation and data var ids = HttpContext.Current.Request["request_ids"]; // if we have data if(ids != null) { // make batch graph request for request details var requestIds = ids.Split(',').Select(i => long.Parse(i)).ToList(); var fbApp = new FacebookWebClient([AppId],[AppSecret]); dynamic parameters = new ExpandoObject(); parameters.ids = ids; dynamic requests = fbApp.Get(parameters); // cycle through graph results and do stuff dynamic req = null; for(int i=0;i<requestIds.Count;i++) { try { req = requests[requestIds[i].ToString()]; // do stuff with request, save to DB, etc. } catch (Exception ex) { // error in finding request, continue... } } } 
0
source share

You can access the list of user IDs as part of the returned data

 FB.ui({ method: 'apprequest', message: 'Use this thing', }, function(result){ //a list of ids are in here result.to; }); 
0
source share

All Articles