Search code examples
ruby-on-railsfacebookfacebook-graph-apifb-graph

FbGraph: Facebook events have a map, but the venue returned is not geolocated


I'm not sure it's a fbgraph bug. In fact I'm pretty sure it's not, but I would like to understand why some facebook events display a map, but when I fetch them with FbGraph, the venue returned has no venue information.

I'm doing:

FbGraph::Event.fetch("1314214...", access_token: "ABABZ...")

And the venue, which is part of the response, is

@venue=#<FbGraph::Venue:0x007f8657de20a8 @latitude=nil, @longitude=nil, @street=nil, @city=nil, @state=nil, @zip=nil, @country=nil>

Why is that?


Solution

  • Facebook will show a map even if the event creator never supplied geo-location data. So, if you don't receive location data it's because the event creator never supplied the data.

    Added: Relevant info from the discussion below...

    Facebook may draw a map of a given address by converting that address to latitude/longitude, however, you as the programmer don't have access to those coordinates. Facebook will only return coordinates if the user specifically entered them (usually by choosing a point on a map).

    Added: so maybe the above is wrong...

    After re-reading your question, I realize that my answer may not apply to your situation. It looks like what Facebook is actually doing is returning the location ID and leaving it up to you to query info about that place. Keep in mind that Facebook used to store events in it's database with individual data fields for address, city, state, etc. However, Facebook seems to be slowly transitioning to store only place ID's. (But it still has those fields available to programmers).

    It used to be that you could programmatically create an event with a street, city, state, etc. Now, the only field you can supply is the place ID. The same goes with the event creation front-end from your events page -- you must find a place which Facebook recognizes, you can't simply enter an arbitrary address.

    However, if you create an event programmatically and then go to edit it from Facebook you will find that you can enter an address manually.