Javascript 显示地点/位置名称而不是ID
我正在尝试筛选并显示帖子中包含位置/地点的好友状态更新。我已经尝试了很多次迭代,但除了位置“id”之外,无法获得要显示的位置。我只想显示好友发布的包含实际位置的状态更新。我尝试过将对象从“stream”更改为“place”和“location\u post”,但没有成功。任何帮助都将不胜感激。代码如下:Javascript 显示地点/位置名称而不是ID,javascript,php,facebook,Javascript,Php,Facebook,我正在尝试筛选并显示帖子中包含位置/地点的好友状态更新。我已经尝试了很多次迭代,但除了位置“id”之外,无法获得要显示的位置。我只想显示好友发布的包含实际位置的状态更新。我尝试过将对象从“stream”更改为“place”和“location\u post”,但没有成功。任何帮助都将不胜感激。代码如下: window.fbAsyncInit = function () { FB.init({ appId: '<?= $sApplicationId ?>',
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);
}());
我认为没有直接的方法可以做到这一点,但是你可以在客户端加入帖子和地点信息: 职位:
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\u id键上。您到底想显示什么?帖子信息和地点信息混在一起?