1

我正在尝试从 Facebook 获取用户签到并放在 Google 地球/地图上,我搜索了示例,但一无所获(这里和谷歌上)。

现在我的问题是获取用户的 chekins(首先我将分别制作所有 facebook 部分,然后将使用 google earth / maps 收集),即使我请求所有权限,似乎也没有授予我的应用程序权限(用于测试目的)但仍然无法正常工作。

以下是我正在使用的代码:

<!DOCTYPE html> 
<html xmlns:fb="https://www.facebook.com/2008/fbml">
    <head>
        <title>New JavaScript SDK</title>
        <script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function () {
                window.fbAsyncInit = function() {
                    FB.init({
                        appId: 'appidhere', 
                        status: true, 
                        cookie: true,
                        xfbml: true,
                        oauth: true
                    });

                    function updateButton(response) {
                        var button = document.getElementById('fb-auth');

                        if (response.authResponse) {
                            //user is already logged in and connected
                            var userInfo = document.getElementById('user-info');
                            FB.api('/me', function(response) {
                                userInfo.innerHTML = '<img src="https://graph.facebook.com/' + response.id + '/picture">' + response.name;
                                button.innerHTML = 'Logout';

                                //checkin_id, author_uid, page_id, app_id, post_id, coords, timestamp, tagged_uids, message
                                var query =  FB.Data.query('SELECT page_id, coords, tagged_uids, message FROM checkin WHERE author_uid= me()', response.id);
                                query.wait(function(rows) {
                                    document.getElementById('user-checkins').innerHTML =  
                                    'Place: ' + rows[0].page_id + "<br />" + 
                                    'Latitude/Longetude: ' + rows[0].coords + "<br />" + 
                                    'Friends you been with: ' + rows[0].tagged_uids + "<br />" + 
                                    'Message: ' + rows[0].message + "<br />";
                                });
                            });
                            button.onclick = function() {
                                FB.logout(function(response) {
                                    var userInfo = document.getElementById('user-info');
                                    userInfo.innerHTML="";
                                });
                            };
                        } else {
                            //user is not connected to your app or logged out
                            button.innerHTML = 'Login';
                            button.onclick = function() {
                                FB.login(function(response) {
                                    if (response.authResponse) {
                                        FB.api('/me', function(response) {
                                            var userInfo = document.getElementById('user-info');
                                            userInfo.innerHTML = '<img src="https://graph.facebook.com/' + response.id + '/picture" style="margin-right:5px"/>' + response.name;
                                        });
                                    } else {
                                        //user cancelled login or did not grant authorization
                                    }
                                }, {
                                    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'
                                });
                            }
                        }
                    }

                    // run once with current status and whenever the status changes
                    FB.getLoginStatus(updateButton);
                    FB.Event.subscribe('auth.statusChange', updateButton);
                };

                (function() {
                    var e = document.createElement('script'); e.async = true;
                    e.src = document.location.protocol 
                        + '//connect.facebook.net/en_US/all.js';
                    document.getElementById('fb-root').appendChild(e);
                }());
            });
        </script>
    </head>
<body> 

<div id="fb-root"></div>
<h2>Updated JS SDK example</h2><br />
<div id="user-info"></div>
<div id="user-checkins"></div>
<p><button id="fb-auth">Login</button></p>
</body> 
</html>

它显示图片和名称,但不显示签入信息。控制台显示:

Uncaught TypeError: Can not read property 'page_id' of undefined facebook2.html: 31
(anonymous function) facebook2.html: 31
t.__wrapper all.js: 49
(anonymous function) all.js: 127
d all.js: 83
(anonymous function) all.js: 83
w all.js: 18
FB.provide.fire all.js: 83
FB.Class.FB.copy.setProperty all.js: 105
FB.subclass.set all.js: 127
(anonymous function) all.js: 129
w all.js: 18
(anonymous function) all.js: 129
would all.js: 66
q all.js: 63
(anonymous function) all.js: 48
(anonymous function)

其他事情,

由于有几个签到,我如何与他们做一个循环?

在每个签入中,坐标是一个数组,我如何将这个数组转换为纬度/经度?

page_id 给了我一个 id(当然)我喜欢得到这个地方的名字,怎么做?

如果有人可以帮助我,现在谢谢你。

4

1 回答 1

0

好的!

我发现这个http://www.facebookmobileweb.com/hackbook/对我有很大帮助。

我发现了错误,我必须在“Facebook上的应用程序”中设置画布网址,然后权限才起作用......

于 2012-10-03T14:35:29.737 回答