How to retrieve user country using facebook Graph API?

前端 未结 4 1149
南旧
南旧 2020-12-30 03:13

I want to retrieve the logged in user country, and insert it into a div. I succeed making it with the user Name, Gender and Age range, but somewhy I can\'t retrieve the coun

4条回答
  •  情书的邮戳
    2020-12-30 03:44

    To complete what Lix said:

    You can do it with only one call to Graph API, by calling

    /me?fields=name,email,gender,age_range,picture,location{location}

    Indeed, the location object under the user object is a Page object, which has a Location object.

    So, this will give you something like this:

    "location": {
      "location": {
        "city": "Ramat Gan",
        "country": "Israel",
        "latitude": 32.0833,
        "longitude": 34.8167,
        "zip": "<>"
      }
    }
    

    This avoids you to make a double call to Graph API.

提交回复
热议问题