Created
September 10, 2011 16:54
-
-
Save aaronksaunders/1208516 to your computer and use it in GitHub Desktop.
Publish a Facebook checkin using Graph API in Appcelerator
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
Titanium.Facebook.appid = "YOUR APP ID"; | |
Titanium.Facebook.permissions = ['publish_stream', 'read_stream', "user_checkins", "publish_checkins"]; | |
function doFacebookCheckin(_callback) { | |
var getInfo = function(localCallback) { | |
// GOTCHA - You need to stringify the coordinates or the | |
// the API call will fail, this was a PITA to find | |
var data = { | |
"place" : "117464364938130", | |
"coordinates" : JSON.stringify({ | |
'latitude' : 40.7798027, | |
'longitude' : -73.9481371, | |
}), | |
"access_token" : Ti.Facebook.accessToken | |
}; | |
Ti.Facebook.requestWithGraphPath('me/checkins', data, 'POST', function(e2) { | |
if(e2.success) { | |
Ti.API.info("Success"); | |
Ti.API.info(JSON.stringify(e2.result)); | |
if(e2.result) { | |
var data = JSON.parse(e2.result); | |
return; | |
} | |
} else if(e2.cancelled) { | |
Ti.API.error("User Cancelled"); | |
return; | |
} else { | |
Ti.API.error(JSON.stringify(e2)); | |
return; | |
} | |
}); | |
} | |
// do that thing... | |
if(!Titanium.Facebook.loggedIn) { | |
Titanium.Facebook.authorize(); | |
Titanium.Facebook.addEventListener('login', function(e) { | |
if(e.success) { | |
setTimeout(function() { | |
getInfo(); | |
}, 2000); | |
} else if(e.error || e.cancelled) { | |
return; | |
} | |
}); | |
} else { | |
getInfo(); | |
} | |
} | |
doFacebookCheckin(); |
Hi there,
I just came to know that fb checkin has been depreciated in a new API , may I know this code still works or not ?
This can be done using the User/Feed api now.... User/checkin is discontinued
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just wrote a comment up here saying that there was something wrong with the code, but it was my fault in the end! Thank you for this, certainly made work easier :)