Reputation: 21
How can I retrieve the user IDs that were checked in the multi-friend-selector generated by the Application Request Dialog? Ive tried :
FB.ui({ method: 'apprequests',
message: 'Here is a new Requests dialog...'
}, function (response) {
if (response && response.request_ids) {
console.log(response.request_ids);
}
});
But I dont get any results in the console. Thanks
Upvotes: 2
Views: 16112
Reputation: 31
here is an article on how to get request objects in PHP and how to get information out of the request object. http://denverapps.co/list-of-user-ids-from-requests-dialog-migrating-from-fb-request-form-to-fb-ui-apprequests-facebook-api-javascript-php
Upvotes: 3
Reputation: 54
Here is my code.
FB.ui({
method: 'apprequests',
message: 'Here is a new Requests dialog...'
}, function(res){
if (!res || !res.request_ids) { /* user canceled */ return; }
var req_ids = res.request_ids;
var _batch = [];
for(var i=0; i<req_ids.length; i++ ){
_batch.push({"method":"get","relative_url":req_ids[i]});
}
if(_batch.length>0){
FB.api('/','POST',{batch:_batch},function(res){
//res contains uids.
});
}
});
Upvotes: 3
Reputation: 29
request_ids does not exist anymore, just wanted to post the latest code
FB.ui({
method: 'apprequests',
message: "my app request message",
picture: 'url to my image',
max_recipients: 'number of recipients in integer (max 50, 30 for IE6/7)'
}, function(response) {
if(response && response.hasOwnProperty('to')) {
for(i = 0; i < response.to.length; i++) {
console.log("" + i + " ID: " + response.to[i]);
}
}
});
Upvotes: 2
Reputation: 980
heres the new response.to code thanks to pferdefleisch
FB.ui({
method: 'apprequests',
message: "Test",
data: "whatever"
}, function (response) {
if (response && response.to) {
for (var j = 0; j < response.to.length; j++) {
alert(response.to[j]);
}
}
});
Upvotes: 1
Reputation: 3809
In the app I am working on right now this
response.request_ids
doesn't exist anymore.
It seems to now use
response.to
which is providing me with user ids, not request ids. The request ids are nowhere to be found but that's ok with me because I want the user ids :)
Here's what my response object looks like in the inspector
Object
request: 12345678909876
to: Array[2]
__proto__: Object
Update:
I just found this in the Facebook API Documentation. It illustrates what I said above.
It turns out that there is a Requests 2.0 API
http://developers.facebook.com/docs/reference/dialogs/requests/
under the headline Updated Request ID Format
Upvotes: 1
Reputation: 3722
I tried the same code ..... first of all "response.request_ids" gives you the Request ids not the user ids FB.api('/me/apprequests/?request_ids=' gives you the data associated with request_ids.. But in my case the problem is that i'm getting a random User id of a friend whom I didn't even select
FB.ui({
method: 'apprequests',
message: 'You should learn more about this awesome game.', data: 'tracking information for the user'
},function(response) {
if (response && response.request_ids) {
//alert(typeof(response.request_ids));
//alert(response.request_ids);
alert (response.request_ids);
len=response.request_ids.length;
alert(len);
if (len>2) {
alert("Select no more than one friend");
}
else {
user_req_id = response.request_ids[0];
alert (user_req_id);
FB.api('/me/apprequests/?request_ids='+toString(user_req_id),
function(response) {
alert(response);
alert(response['data'][0]['from']['id']);
});
}
}
else {
alert('Post was not published.');
}
});
Upvotes: 0