Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Graph API Filter Search Results

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.

like image 235
Medalist Avatar asked Feb 13 '14 09:02

Medalist


1 Answers

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.

like image 194
Abhik Chakraborty Avatar answered Oct 11 '22 04:10

Abhik Chakraborty