Green
Green

Reputation: 30805

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.

Upvotes: 0

Views: 182

Answers (1)

C3roe
C3roe

Reputation: 96339

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

Upvotes: 3

Related Questions