Guest User

Untitled

a guest
Jan 22nd, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. Titanium.Facebook.appid = "YOUR APP ID";
  2. Titanium.Facebook.permissions = ['publish_stream', 'read_stream', "user_checkins", "publish_checkins"];
  3.  
  4. function doFacebookCheckin(_callback) {
  5.  
  6. var getInfo = function(localCallback) {
  7.  
  8. // GOTCHA - You need to stringify the coordinates or the
  9. // the API call will fail, this was a PITA to find
  10. var data = {
  11. "place" : "117464364938130",
  12. "coordinates" : JSON.stringify({
  13. 'latitude' : 40.7798027,
  14. 'longitude' : -73.9481371,
  15. }),
  16. "access_token" : Ti.Facebook.accessToken
  17. };
  18. Ti.Facebook.requestWithGraphPath('me/checkins', data, 'POST', function(e2) {
  19.  
  20. if(e2.success) {
  21.  
  22. Ti.API.info("Success");
  23. Ti.API.info(JSON.stringify(e2.result));
  24.  
  25. if(e2.result) {
  26. var data = JSON.parse(e2.result);
  27. return;
  28. }
  29.  
  30. } else if(e2.cancelled) {
  31. Ti.API.error("User Cancelled");
  32. return;
  33. } else {
  34. Ti.API.error(JSON.stringify(e2));
  35. return;
  36. }
  37.  
  38. });
  39. }
  40. // do that thing...
  41. if(!Titanium.Facebook.loggedIn) {
  42. Titanium.Facebook.authorize();
  43.  
  44. Titanium.Facebook.addEventListener('login', function(e) {
  45. if(e.success) {
  46. setTimeout(function() {
  47. getInfo();
  48. }, 2000);
  49. } else if(e.error || e.cancelled) {
  50. return;
  51. }
  52. });
  53. } else {
  54. getInfo();
  55. }
  56. }
  57.  
  58. doFacebookCheckin();
Add Comment
Please, Sign In to add comment