Skip to content

Instantly share code, notes, and snippets.

@aaronksaunders
Created September 10, 2011 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save aaronksaunders/1208516 to your computer and use it in GitHub Desktop.
Save aaronksaunders/1208516 to your computer and use it in GitHub Desktop.
Publish a Facebook checkin using Graph API in Appcelerator
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();
@Gorenjai
Copy link

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 :)

@dhavalkakkad
Copy link

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 ?

@GauravGGTrilyo
Copy link

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