Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to filter by category in FQL

As you can see here,

Businesses have their category information: Local Business, Sport, Education.. etc. It is the field "category".

I would like to know, is there a way to filter businesses by their category and position with FQL? I haven't found how to do it. For instance: give me all the sports center in this circle (lat, lon, radius).

thanks

like image 757
Pablo Castilla Avatar asked Feb 22 '11 19:02

Pablo Castilla


3 Answers

The "category" attribute in the "page" table is called "type". Here is a query to filter the logged-in user's "local business" likes:

SELECT page_id, name, description, type, pic, fan_count
FROM page
WHERE
   page_id IN (SELECT page_id FROM page_fan WHERE uid = me())
   AND Type = 'LOCAL BUSINESS'

Run Example

like image 100
Baz Avatar answered Nov 15 '22 07:11

Baz


You can't retrieve pages by category.

The FQL Page table has a field called categories.

You can retrieve the category for a business with FQL like this:

SELECT categories FROM page WHERE page_id = PAGE_ID

where PAGE_ID is the page's Facebook id.

However, categories is not an indexable field. You can't ask for all business in New York which are Florists since "WHERE categories = florist" isn't allowed.

like image 25
onosendai Avatar answered Nov 15 '22 06:11

onosendai


I have been looking for something and haven't found anything. It appears that only the graph api has the category information for a page.

like image 29
Joe Purcell Avatar answered Nov 15 '22 08:11

Joe Purcell