Last active
August 29, 2015 13:56
-
-
Save nicholasdunbar/8809354 to your computer and use it in GitHub Desktop.
Example of using Facebook JavaScript API to do apprequests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FB.ui({ | |
method: 'apprequests', | |
title:'Suggest '+fbAppName+' to your friends', | |
message: 'I thought you would dig this app!', | |
data: 'gameID=96' | |
}, onInviteFriend); | |
//jquery required for ajax function | |
onInviteFriend = function(response) { | |
if (response && response.request_ids) { | |
var idsLength = response.request_ids.length; | |
var idList = ""; | |
var data = {}; | |
var ajaxSettings = {}; | |
for (var i = 0; i < idsLength; i++){ | |
idList += response.request_ids[i]; | |
if (i < idsLength-1){ | |
idList += ","; | |
} | |
} | |
if (idsLength > 0){ | |
data.idList = idList; | |
ajaxSettings = { | |
type: "GET", | |
url: sketchnpass.root+"/ajax/log-invite-sent/", | |
data: data, | |
success: sketchnpass.onSaveInvites | |
}; | |
$.ajax(ajaxSettings); | |
} | |
//was published | |
} else { | |
//was not published | |
} | |
} | |
//see old way of doing it here https://gist.github.com/nicholasdunbar/8809290 | |
//This is an example in the following article: | |
//List of user ids from requests dialog | Migrating from fb:request-form to fb.UI apprequests | |
//found at http://www.actionscript-flash-guru.com/blog/43-list-of-user-ids-from-requests-dialog-migrating-from-fbrequest-form-to-fbui-apprequests-facebook-api-javascript-php-.php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment