Home » Php » php – Facebook API Search – Search for Groups?

php – Facebook API Search – Search for Groups?

Posted by: admin July 12, 2020 Leave a comment

Questions:

I have been testing the Facebook php sdk. I am able to search for pages & places but not groups. According to the documentation, this should return groups…

https://graph.facebook.com/search?q=programming&type=group

The below code works. If I change the type from “page” to “group”, the code fails. I do not get an exception:

$query = urlencode('Harlem');

$type = 'page';


$results = $facebook->api('/search?q='.$query.'&type='.$type);
How to&Answers:

It depends on what kind of Access Token you’re using. As of https://developers.facebook.com/docs/reference/api/search/#access_tokens searches for pages require an App Access Token, whereas searches for Groups require an User Access Token. Please check accordingly.