1
votes

Is it possible to get the place for a page post?

The Graph API documentation for a post object says there is a place field that has place id, name, longitude, latitude, etc.

Here are the steps I followed to test this:

  • In Facebook UI, I posted to my page with the location enabled
  • Using Graph API, I read page posts (https://graph.facebook.com/{PAGE_ID}/feed?access_token={TOKEN}&since={STARTDATE}&until={ENDDATE})
  • I observed that the JSON response contained my post and no place field was present.

Thanks for your help!

1

1 Answers

0
votes

I know this is an old post, but you can get location information from using the ?fields=place option when querying the specific post details.

Here is the code I'm using to fetch posts and their location from a Facebook Page. You can replace /posts with /feed for your example

FB.api('/{PAGE_ID}/posts', function(response) {
  if (!response.error) {
    var posts = response.data;
    for (i = 0; i < posts.length; i++)
    {
      var post = posts[i];
      FB.api('/' + post.id + '?fields=place', function(response) {
        if (!response.error && response.place) {
          post.place = response.place;
        }
        console.log(post);
      });
    }
  }
});

You can also use this method with ?fields=attachments to get any pictures or videos attached to the post.

Hope this helps 19 months later :]