Search code examples
facebookfacebook-graph-apilocationfieldfacebook-checkins

Facebook Graph API: Getting latitude/longitude of a Checkin via Fields API (optimized calling)


I'd like to know whether there is a way to directly get the latitude/longitude fields via the Facebook Graph API.

The background is that I want to reduce the amount of data which is returned by the Graph API by getting rid of fields which are not of interest for my application.

I know there's something like this working in the Graph API Explorer:

me/?fields=id,checkins.fields(id,place.fields(id,location),created_time)

It returns the following:

{
"id": "12345", 
"checkins": {
"data": [
  {
    "id": "101511234546244", 
    "place": {
      "id": "170048419682121", 
      "location": {
        "street": "", 
        "city": "Frankfurt", 
        "state": "", 
        "country": "Germany", 
        "zip": "", 
        "latitude": 50.108641831527, 
        "longitude": 8.6654729704433
      }
    }, 
    "created_time": "2012-11-08T08:30:48+0000"
  }
]
}

As I don't need the address parts of the location, I'd really like to get rid of them as well. If I try this the follwoing way, it doesn't work:

me?fields=id,checkins.fields(id,place.fields(id,location.fields(latitude,longitude)),created_time)

The result is

{
"id": "12345", 
"checkins": {
"data": [
  {
    "id": "101511234546244", 
    "place": null, 
    "created_time": "2012-11-08T08:30:48+0000"
  }
]
}

Did somebody have success in doing something similar? If so, I'd be great if you could let me know. Thanks!


Solution

  • According to the API documentation and the Graph API explorer, Subfields are not supported by location so you are unable to extract just latitude and longitude from the location object.