Facebook Graph API Filter Search Results

13,269

No this is not possible at this time may be in future it may get implemented.

The graph api search needs the API end point as

https://graph.facebook.com/search?q=QUERY&type=OBJECT_TYPE

Here Possible object types are - post,event,user, group etc.

https://developers.facebook.com/docs/reference/api/search/

The returned value what you saw are fields and "type" status, photo, link etc are the fields within the returned data, you can however narrow down your returned fields by specifying the

&fields=id,name,picture,type etc

You can see the docs here "Available Search Types" in the following URL

https://developers.facebook.com/docs/graph-api/using-graph-api

You need to loop through the result and display the desired one as you need.

Share:
13,269
Admin
Author by

Admin

Updated on July 23, 2022

Comments

  • Admin
    Admin almost 2 years

    I'm using PHP SDK to get the results for a certain keyword within public posts

    $q = "something";
    $results = $facebook->api('/search/','get',array('q'=>$q,'type'=>'post','limit'=>10));
    

    this query returns a similar result to this one:

    Array
    (
        [id] => id
        [from] => Array
            (
                [name] => Some Random Name
                [id] => id
            )
    
        [message] => Hello hello hello. something
        [privacy] => Array
            (
                [value] => 
            )
    
        [type] => status
        [created_time] => 2013-10-31T10:20:58+0000
        [updated_time] => 2013-10-31T10:20:58+0000
    )
    

    as you see the [type] => status section, this can be status, photo, link etc. I'd like to get only photos from public posts which contain the search keyword (in other words, search in public posts which contain $q and filter/get/limit 10 results which have only [type] => photo value)

    How can i achieve this? I assume FQL can't help on this since i search within public posts.

  • Admin
    Admin about 10 years
    unfortunately yes, that looping is the thing which i'm not keen on to do, but guess there is no choice than this at the moment
  • Abhik Chakraborty
    Abhik Chakraborty about 10 years
    Thats correct we need to wait for some new features and I am sure FB will add these features in future but they just dont want to give everything all at a time.