Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I filter pages from Facebook’s Graph API by a specific category?

I'm trying to fetch from Facebook's Graph API pages which belong to a specific category.

Currently I'm using this URL call

https://graph.facebook.com/search?type=place&center=42.21,20.7&distance=5000&access_token=&fields=id,link,name,cover,category,category_list,location,likes

How could I filter specific categories which are found in the category_list so I only get pages that belong to those categories?

like image 383
Kreshnik Hasanaj Avatar asked Dec 06 '25 16:12

Kreshnik Hasanaj


1 Answers

Unfortunately you couldn't filter by category_list, but you can do something similar with the categories parameter. You just need to add the categories parameter to the end of your link, and set the q parameter (with that, you can search for the name of the place, but you can set it to *). For me it returned an empty object without the q parameter, but you may worth to try without that.
So, your search will look like this, if you would like to search for places with categories named food & beverage:

graph.facebook.com/search?type=place&center=42.21,20.7&distance=5000&access_token=&fields=id,link,name,cover,category,category_list,location,likes&categories=["FOOD_BEVERAGE"]&q=*

For more information about the parameters and the possible values of the categories parameter, read the Graph API search documentation:
https://developers.facebook.com/docs/places/search

like image 155
Laios Avatar answered Dec 08 '25 10:12

Laios



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!