Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List of countries and cities to be used in Facebook Graph API for targeting

I am looking for a list of countries/states/cities that can be used with Facebook Graph API when publishing targeted posts.

I found one JSON file available on this page but the file doesn't parse correctly and I also doubt whether it can be used for post targeting since the file is for advertisements.

Also, I am not sure whether the third party data like the one provided by MaxMind can be used directly with Facebook API.

Does anyone have such a list or can atleast point me to a right direction?

like image 295
Aditya Avatar asked Aug 29 '11 07:08

Aditya


3 Answers

The answer is here: https://developers.facebook.com/docs/reference/ads-api/get-autocomplete-data/

like image 85
Eladio Avatar answered Oct 23 '22 21:10

Eladio


To check what countries are available you could just get a response from this endpoint:

URL: https://graph.facebook.com/API_VERSION/search?type=adgeolocation&location_types=['country']

HTTP_METHOD: GET

You also have to set your access token in the URL.

To just see the fields key and name and a larger quantity of countries without being paginated this would be the complete URL:

https://graph.facebook.com/API_VERSION/search?type=adgeolocation&location_types=['country']&fields=key,name&limit=1000

like image 37
Alan Albertengo Avatar answered Oct 23 '22 22:10

Alan Albertengo


For countries: search?type=adgeolocation&location_types=['countries']&limit=1000

For regions: search?type=adgeolocation&location_types=['region']&limit=1000&country_code=PT

Hope that helps :)

like image 1
Rafael Pereira Avatar answered Oct 23 '22 23:10

Rafael Pereira