Search code examples
facebookfacebook-graph-apifacebook-fql

Facebook - obtain location /places ID via location name


I'm able to return a location's details by sending a query via the graph api with the location's ID, however I'm looking to achieve the reverse - effectively find location id by sending a request containing the location name (city, state etc). Is this possible?


Solution

  • This is possible under a few different approaches. You can either search using long / lat positions and put the place name into the query. This search will search places only.

    Do the following

    https://graph.facebook.com/search?q=ritual&type=place&center=37.76,-122.427&distance=1000&access_token=mytoken.

    This will return ritual coffee.

    Another way is to search through facebook pages using the following https://graph.facebook.com/search?q=ritual%20coffee&type=page&access_token=mytoken

    This way is more difficult as you will obviously need to parse the list in more detail.