1

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!

Tobi
  • 31,405
  • 8
  • 58
  • 90

1 Answers1

2

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.

Niraj Shah
  • 15,087
  • 3
  • 41
  • 60
  • Thanks for your reply! Could you maybe post the URL to the documentation? The Graph API explorer doesn't show me the message you mentioned unfortunately. – Tobi Sep 04 '13 at 07:03
  • Have a look at: http://developers.facebook.com/tools/explorer?method=GET&path=me%2Fcheckins%3Ffields%3Dplace%2Clocation.fields(latitude%2Clongitude) – Niraj Shah Sep 05 '13 at 14:45
  • Yeah, but I think your query is wrong: location is a sub-object of the place object. From my perspective the http://developers.facebook.com/tools/explorer?method=GET&path=me%2Fcheckins%3Ffields%3Dplace.fields(location.fields(latitude%2Clongitude)) query should be conceptually correct, but it return null as place. – Tobi Sep 09 '13 at 10:27
  • Either way, the error message is clear. Facebook doesn't let you pull out subfields from the location object. – Niraj Shah Sep 12 '13 at 11:07