Facebook location geocode - facebook

When requesting users to register with Facebook connect I can access their hometown (which is a location id as well as the name). Is anyone aware if it is possible to get the geo-coded location for this (e.g. retrieve the latitude/longitude as well as the name?) I cannot see it as part of the documentation.
I could geocode it using the hometown with the google geo coding service, but was wondering if another option?

It's not possible. The information you can retrieve about a user is here. As you can see the only location based info is hometown (like you said). If you want latitude/longitude you will have to calculate it yourself from the hometown.

You can grab the id out of the location record that is returned on the user:
"location": {
"id": "106224666074625",
"name": "Austin, Texas"
},
and make a graph call:
GET https://graph.facebook.com/106224666074625?fields=location
which returns:
{
"location": {
"street": "",
"zip": "",
"latitude": 30.2672,
"longitude": -97.7639
},
"id": "106224666074625"
}

Related

Is it possible to obtain the Instagram 'location-id' given the coordinates?

I am trying to obtain the Instagram location-id of a location, but I have only the coordinates of that location. Is it possible to get it automatically by using the API?
Thank you,
You have to use the location/search endpoint to search the coordinate and it will show all the nearby locations.
https://api.instagram.com/v1/locations/search?lat=LAT&lng=LNG&access_token=ACCESS-TOKEN
https://www.instagram.com/developer/endpoints/locations/#get_locations_search
Request Url : https://api.instagram.com/v1/locations/search?access_token=&lat=12.8282669&lng=80.0511868&distance=100&count=1
Getting improper response When I try above location search ,
Response:
{
"data": [
{
"id": "112419772139227",
"name": "CEOA Matriculation School",
"latitude": 9.90604,
"longitude": 78.10873
}
],
"meta": {
"code": 200
}
}

How to get user's home country from hometown id?

FB returns hometown like this:
hometown: {
id: "106050279435951",
name: "Quezon City, Philippines"
},
How to get country using that hometown id? I see that I can get country name form name: "Quezon City, Philippines", but I'm curious if FB Graph API has means to use that hometown id to get some special value about country.
The hometown field refers to a page, and that page in turn has a location.
106050279435951?fields=location
Result:
{
"location": {
"city": "Quezon City",
"country": "Philippines",
"latitude": 14.6439,
"longitude": 121.037
},
"id": "106050279435951"
}
You can also use Field Expansion to get this info in one go while requesting other user info,
me?fields=hometown{location},...

How can Mobile App Builder get location (lat, long) data from Cloudant?

I am trying to read location type data from Cloudant into Mobile App Builder (MAB). It looks like MAB is unable to parse it. If I manually create the column still is unable to match it with the data coming from Cloudant
{
"_id": "d07165c0087a05b8ae732266dc37f106",
"_rev": "8-76f0947057bf237bc897adc20f838ce9",
"Name": "Morrisville Location",
"Address": "87 Peste Drive",
"Phone": "919-278-1122",
"Email": "morrisville#store.com",
"Location": {
"Latitude": "35.808514",
"Longitude": "-78.812794"
}
}
What format should I use for location data so MAB can parse it ?
The following worked for me:
{
"_id": "d07165c0087a05b8ae732266dc37f106",
"_rev": "8-76f0947057bf237bc897adc20f838ce9",
"Name": "Morrisville Location",
"Address": "87 Peste Drive",
"Phone": "919-278-1122",
"Email": "morrisville#store.com",
"Location": {
"type": "Point",
"coordinates": [-78.812794, 35.808514]
}
}
Note: Order in coordinates array is [longitude, latitude]
Reference: https://docs.cloudant.com/geo.html and http://geojson.org/geojson-spec.html#appendix-a-geometry-examples
This very first experimental version of Mobile App Builder does not support nested objects at this time.
Here, I've removed the nested object and it works:
See:
IBM mobile app builder does not see documents in Cloudant database, why?
To answer my own question: This is not possible today given the limited parsing features of the current tool. Thanks for the comments and feedback.

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!
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.

Facebook test user - graph api does not return first name and last name

For a few days now, I am suddenly experiencing a strange behavior with the graph API access test users' friends.
When fetching the user objects of friends of my test user (which are test users as well), the first name and last name data is missing.
When I use the browser with
https://graph.facebook.com/100001234567890
I get the response
{
"id": "100001234567890",
"name": "Dorothee Chengman",
"first_name": "Dorothee",
"last_name": "Chengman",
"link": "http://www.facebook.com/people/Dorothee-Chengman/100001234567890",
"gender": "female",
"locale": "de_DE"
}
But when accessing it in my app with a request
https://graph.facebook.com/100001234567890?access_token=imagineTokenHere&format=json
I get the response
{
"id": "100001234567890",
"link": "http://www.facebook.com/profile.php?id=100001234567890",
"birthday": "11/03/1980",
"gender": "female",
"locale": "de_DE",
"updated_time": "2011-12-04T16:48:17+0000"
}
So, suddenly, the first name and last name are missing :-(
Please help.
This is a known issue, being tracked in the bug tracker, it should only affect test users:
https://developers.facebook.com/bugs/320132691332575