{"id":1754,"date":"2022-08-30T15:19:10","date_gmt":"2022-08-30T15:19:10","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/30\/facebook-javascript-sdk-get-user-checkins-to-put-on-google-maps-earth-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:19:10","modified_gmt":"2022-08-30T15:19:10","slug":"facebook-javascript-sdk-get-user-checkins-to-put-on-google-maps-earth-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/facebook-javascript-sdk-get-user-checkins-to-put-on-google-maps-earth-collection-of-common-programming-errors\/","title":{"rendered":"Facebook Javascript SDK get user checkins to put on google maps\/earth-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m trying to get user checkins from Facebook and put on Google Earth \/ Maps, I searched for examples, but found nothing (here and on google).<\/p>\n<p>Right now my problem is to get the users&#8217; chekins (first I&#8217;ll make all the facebook part separately and then will gather with google earth \/ maps), it seems that is not giving permissions to my application, even though I request all permissions (for testing purposes) and still not working.<\/p>\n<p>Following is the code I&#8217;m using:<\/p>\n<pre><code> \n\n    \n        New JavaScript SDK\n        \n        \n            $(document).ready(function () {\n                window.fbAsyncInit = function() {\n                    FB.init({\n                        appId: 'appidhere', \n                        status: true, \n                        cookie: true,\n                        xfbml: true,\n                        oauth: true\n                    });\n\n                    function updateButton(response) {\n                        var button = document.getElementById('fb-auth');\n\n                        if (response.authResponse) {\n                            \/\/user is already logged in and connected\n                            var userInfo = document.getElementById('user-info');\n                            FB.api('\/me', function(response) {\n                                userInfo.innerHTML = '<img decoding=\"async\" src=\"https:\/\/graph.facebook.com\/'%20+%20response.id%20+%20'\/picture\" \/>' + response.name;\n                                button.innerHTML = 'Logout';\n\n                                \/\/checkin_id, author_uid, page_id, app_id, post_id, coords, timestamp, tagged_uids, message\n                                var query =  FB.Data.query('SELECT page_id, coords, tagged_uids, message FROM checkin WHERE author_uid= me()', response.id);\n                                query.wait(function(rows) {\n                                    document.getElementById('user-checkins').innerHTML =  \n                                    'Place: ' + rows[0].page_id + \"<br \/>\" + \n                                    'Latitude\/Longetude: ' + rows[0].coords + \"<br \/>\" + \n                                    'Friends you been with: ' + rows[0].tagged_uids + \"<br \/>\" + \n                                    'Message: ' + rows[0].message + \"<br \/>\";\n                                });\n                            });\n                            button.onclick = function() {\n                                FB.logout(function(response) {\n                                    var userInfo = document.getElementById('user-info');\n                                    userInfo.innerHTML=\"\";\n                                });\n                            };\n                        } else {\n                            \/\/user is not connected to your app or logged out\n                            button.innerHTML = 'Login';\n                            button.onclick = function() {\n                                FB.login(function(response) {\n                                    if (response.authResponse) {\n                                        FB.api('\/me', function(response) {\n                                            var userInfo = document.getElementById('user-info');\n                                            userInfo.innerHTML = '<img decoding=\"async\" src=\"https:\/\/graph.facebook.com\/'%20+%20response.id%20+%20'\/picture\" style=\"margin-right:5px\" \/>' + response.name;\n                                        });\n                                    } else {\n                                        \/\/user cancelled login or did not grant authorization\n                                    }\n                                }, {\n                                    scope:'user_about_me, user_activities, user_birthday, user_checkins, user_education_history, user_events, user_groups, user_hometown, user_interests, user_likes, user_location, user_notes, user_photos, user_questions, user_relationships, user_relationship_details, user_religion_politics, user_status, user_subscriptions, user_videos, user_website, user_work_history, email, friends_about_me, friends_activities, friends_birthday, friends_checkins, friends_education_history, friends_events, friends_groups, friends_hometown, friends_interests, friends_likes, friends_location, friends_notes, friends_photos, friends_questions, friends_relationships, friends_relationship_details, friends_religion_politics, friends_status, friends_subscriptions, friends_videos, friends_website, friends_work_history, read_friendlists, read_insights, read_insights, read_mailbox, read_requests, read_stream, xmpp_login, ads_management, create_event, manage_friendlists, manage_notifications, user_online_presence, friends_online_presence, publish_checkins, publish_stream, rsvp_event, publish_actions, user_actions.music, user_actions.news, user_actions.video, user_games_activity, friends_actions.music, friends_actions.news, friends_actions.video, friends_games_activity'\n                                });\n                            }\n                        }\n                    }\n\n                    \/\/ run once with current status and whenever the status changes\n                    FB.getLoginStatus(updateButton);\n                    FB.Event.subscribe('auth.statusChange', updateButton);\n                };\n\n                (function() {\n                    var e = document.createElement('script'); e.async = true;\n                    e.src = document.location.protocol \n                        + '\/\/connect.facebook.net\/en_US\/all.js';\n                    document.getElementById('fb-root').appendChild(e);\n                }());\n            });\n        \n    \n \n\n\n<\/code><\/pre>\n<h2><code>Updated JS SDK example<\/code><\/h2>\n<pre><br \/>\n\n\n<br \/>Login\n \n\n<\/pre>\n<p><code>It shows the picture and name, but not the checkin information. The console shows:<\/code><\/p>\n<pre><code><code>Uncaught TypeError: Can not read property 'page_id' of undefined facebook2.html: 31\n(anonymous function) facebook2.html: 31\nt.__wrapper all.js: 49\n(anonymous function) all.js: 127\nd all.js: 83\n(anonymous function) all.js: 83\nw all.js: 18\nFB.provide.fire all.js: 83\nFB.Class.FB.copy.setProperty all.js: 105\nFB.subclass.set all.js: 127\n(anonymous function) all.js: 129\nw all.js: 18\n(anonymous function) all.js: 129\nwould all.js: 66\nq all.js: 63\n(anonymous function) all.js: 48\n(anonymous function)\n<\/code><\/code><\/pre>\n<p>Other things,<\/p>\n<p>Since there are several checkins, how I do to do a loop with them?<\/p>\n<p>Within each checkin, coords is an array, how do I transform this array into latitude \/ longetude?<\/p>\n<p>The page_id gives me an id (of course) I like to get the name of the place, how?<\/p>\n<p>If someone can help me, thank you now.<\/p>\n<p id=\"rop\"><small>Originally posted 2013-11-30 22:01:28. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I&#8217;m trying to get user checkins from Facebook and put on Google Earth \/ Maps, I searched for examples, but found nothing (here and on google). Right now my problem is to get the users&#8217; chekins (first I&#8217;ll make all the facebook part separately and then will gather with google earth \/ maps), it seems [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1754","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1754","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1754"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1754\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1754"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1754"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1754"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}