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

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},...

Related

Uber API rider rating

Can I retrive rider rating from Uber API ?
There is only '/v1.2/me' endpoint, but it's returning only:
{
"picture": "https://d1w2poirtb3as9.cloudfront.net/f3be498cb0bbf570aa3d.jpeg",
"first_name": "Uber",
"last_name": "Developer",
"uuid": "f4a416e3-6016-4623-8ec9-d5ee105a6e27",
"rider_id": "8OlTlUG1TyeAQf1JiBZZdkKxuSSOUwu2IkO0Hf9d2HV52Pm25A0NvsbmbnZr85tLVi-s8CckpBK8Eq0Nke4X-no3AcSHfeVh6J5O6LiQt5LsBZDSi4qyVUdSLeYDnTtirw==",
"email": "uberdevelopers#gmail.com",
"mobile_verified": true,
"promo_code": "uberd340ue"
}
...without rider rating
Those appear to be the expected returned fields according to the documentation. Rider rating is not one of the returned fields from that profile endpoint:
https://developer.uber.com/docs/riders/references/api/v1.2/me-get

Facebook Graph API - Get user profile from conversations

by using Facebook Graph API I can fetch the conversations between users and my page. One of the returned conversations looks like this:
{
"message": "message content",
"from": {
"name": "My Page's Name",
"email": "198301820627381#facebook.com",
"id": "198301820627381",
},
"to": {
"data": [
{
"name": "John Doe",
"email": "396169264164870#facebook.com",
"id": "396169264164870",
}
]
},
"id": "m_mid.$cAADurJ0X8UhnJ3tfxVg9jYXJW5fp"
}
I see that I got the user's id field. How can I fetch this user's profile (first name, last name, profile pic) base on this field ? (or is there another way ?)
I followed the Graph API's User Reference but all I got are the user's id and name (which I already have from the returned conversation).
profile_pic only works for PSIDs (Messenger bot events), for ASIDs just use the picture field instead

How to get gender of users attending some event (Facebook Graph API)?

Is there a way to get gender of facebook users via Facebook Graph API, that are attending some event? Or just by users' ids?
You can consume the events/attending endpoint:
https://developers.facebook.com/docs/graph-api/reference/v2.2/event/attending
Your request would be /{TheEventId}/attending
Which returns a list of user objects:
https://developers.facebook.com/docs/graph-api/reference/v2.2/user
...which looks like this:
{
"data": [
{
"name": "What What",
"rsvp_status": "attending",
"id": "10152412233197215"
},
{
"name": "What What",
"rsvp_status": "attending",
"id": "1682602711966379"
},
{
"name": "What What",
"rsvp_status": "attending",
"id": "10201675684423330"
}
]
You would then need to use the user id to query for each user's details. The user object has a gender field.
{
"id": "10142215948176947",
"gender": "male",
...
}
Also note the permission limitations:
gender & locale can only be accessed if:
The person queried is the person using the app.
The person queried is using the app, and is a friend of the person using the app.
The person queried is using the app, is not a friend of the person using the app, but the app includes either an app access token or
an appsecret_proof argument with the call

facebook api, is event id universally unique

The user's event data is as below. I'm wonder the id 157881474402440 is unique among all events (private, public, belong to any person) in Facebook graph since I'm intending to use it to export to a calendar system as the UID of event (I'll append it with something like "_facebook"). Tks
"events": {
"data": [
{
"name": "Return match vs Wollongong",
"start_time": "2013-08-10T14:00:00+1000",
"end_time": "2013-08-10T17:00:00+1000",
"timezone": "Australia/Sydney",
"location": "Wentworth park field 1",
"rsvp_status": "attending",
"id": "157881474402440"
}
],
Every object on facebook has unique object id. you can verify it by getting the event details from two different facebook accounts having access to the event.

Facebook location geocode

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"
}