显示地点/位置名称而不是ID

时间:2014-02-10 05:16:11

标签: javascript php facebook

我正在尝试过滤并显示我的朋友状态更新,其中包含帖子中包含的位置/地点。我尝试过多次迭代,但无法显示位置(除了地点'id'。我想只显示朋友发布的状态更新,其中包含实际位置。我尝试从'stream'更改对象没有运气的'place'和'location_post'。非常感谢任何帮助。这是代码:

window.fbAsyncInit = function () {
    FB.init({
        appId: '<?= $sApplicationId ?>',
        status: true,
        cookie: true,
        xfbml: true,
        oauth: true
    });

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

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

                // get friends activity feed
                iPid = response.id;
                if (iPid > 0) {
                    FB.api({ // call fql.query
                        method: 'fql.query',
                        query: "SELECT post_id, actor_id, type, description, place, permalink, message FROM stream WHERE filter_key in (SELECT filter_key FROM stream_filter WHERE      uid = me() AND type = 'newsfeed') ORDER BY place DESC"
                    }, function (response) {

                        $('#results').html(
                        $('#facebookTemplate').render(response));
                    });
                }
            });

            button.onclick = function () {
                FB.logout(function (response) {
                    window.location.reload();
                });
            };
        } else {
            button.onclick = function () {
                FB.login(function (response) {
                    if (response.authResponse) {
                        window.location.reload();
                    }
                }, {
                    scope: 'read_stream'
                });
            }
        }
    }

    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);
}());

1 个答案:

答案 0 :(得分:0)

我认为没有直接的方法可以做到这一点,但您可以在客户端加入帖子和地点信息:

文章:

SELECT post_id, actor_id, type, description, place, permalink, message from stream where post_id in (select post_id from location_post where author_uid in (select uid2 from friend where uid1=me()) and post_id)

的地方:

SELECT page_id, location from page where page_id in (select page_id from location_post where author_uid in (select uid2 from friend where uid1=me()) and post_id)

联接应位于posts.place = places.page_id键上。

相关问题