dimanche 29 mars 2015

Parsing the response object from sending a Facebook Invite Friend Request

I am working with the Facebook Javascript SDK and I am trying to set up a rewards system for sending invites to Friends. Basically, I want to give the user points for simply sending invites to their friends using the friend invite dialog provided by the Facebook Javascript SDK. That said, I set everything up based on the Friend Smash tutorial on the FB developers website and I am creating a custom, multi-friend selector to send invites. The invite dialog comes up properly and the invite sends correctly.


The Javascript that sends the invite looks like this:



function sendRequest() {
// Get the list of selected friends
var sendUIDs = '';
var mfsForm = document.getElementById('mfsForm');
for(var i = 0; i < mfsForm.friends.length; i++) {
if(mfsForm.friends[i].checked) {
sendUIDs += mfsForm.friends[i].value + ',';
}
}

// Use FB.ui to send the Request(s)
FB.ui({method: 'apprequests',
to: sendUIDs,
title: 'Help me get some points!',
message: 'Help me get some points by coming over to XXX and registering to play!',
}, callback);
}


However the request's response object looks like this when sending to one friend:



{request: "412752342228182", to: Array[1]}


And it looks like this when inviting two friends:



{request: "414967121961627", to: Array[2]}


The object contains the "request" field which is the unique request ID for the invite, as expected. The Facebook documentation states I am supposed to get an array of user IDs of the recipients in the response object's "to" field but that strange Array[X] is there instead. Is this the correct response? Am I missing something?


Any help on this is appreciated. Thanks in advance for your time.


Aucun commentaire:

Enregistrer un commentaire