Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Graph API search places by category

I'm currently developing an Android app that uses Facebook graph API to get pages/places based on user's location. I also want to filter the results by category, like restaurants for example. For now I'm just searching for the name "restaurant" like this: https://graph.facebook.com/search?q=restaurant&type=place&center=37.76,-122.427&distance=1000

The problem is that it wont find pages/places that don't have name "restaurant" and it also returns places that don´t have anything to do with restaurants. I also have the language issue, in non-English countries my search will fail completely.

A possible solution I am considering is to get all the places in a range and parse them in my app for the category or name. Obviously this brings a lot of overhead to my app.

I was wondering if there is a better solution like using FQL to get filtered results?

like image 683
Emanuel Canha Avatar asked Nov 03 '22 21:11

Emanuel Canha


1 Answers

There should be, but I can't unravel how.

This FQL query will get you information about all places near a known location:

SELECT name, page_id, categories, description, general_info 
   FROM page WHERE page_id IN 
     (SELECT page_id FROM place WHERE 
        distance(latitude, longitude, "37.76", "-122.427") < 1000
      )

The categories field is an array with the values id and name. Looking at these results, there are a series of category names like "Restaurant": "Italian Restaurant", "Bar/Restaurant, etc.

What I can't find is a way to add a WHERE categories clause to this that returns data.

like image 174
cpilko Avatar answered Nov 09 '22 07:11

cpilko