Reputation: 13
I am trying to filter and display my friends status updates that have a location/place included in the post. I've tried many iterations, but cannot get the location to display (other than the place 'id'. I want to display only status updates posted by friends where an actual location was included. I have tried changing the object from 'stream' to 'place' and 'location_post' with no luck. Any help would be greatly appreciated. Here is the code:
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);
}());
Upvotes: 1
Views: 102
Reputation: 31479
I think there's no direct way to do this, but you can join the post and the place info on the client side:
Posts:
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)
Places:
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)
The join should be on the posts.place = places.page_id
keys.
Upvotes: 0