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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With