Facebook Graph API Filter搜索结果 [英] Facebook Graph API Filter Search Results
问题描述
我正在使用PHP SDK在公开帖子中获取某个关键字的结果
$ q =something ;
$ results = $ facebook-> api('/ search /','get',array('q'=> $ q,'type'=>'post','limit'=> ; 10));
此查询返回与此相似的结果:
Array
pre>
(
[id] => id
[from] => Array
(
[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
)
,您可以看到 [type] =>状态部分,这可以是状态,照片,链接等。我想只收到包含搜索关键字的公开帖子(换句话说,在公开帖子中搜索包含$ q和filter / get / limit 10结果的照片,只有[type] => photo value)
我该如何实现?我假设FQL无法帮助,因为我在公共帖子中搜索。
解决方案此时不可能将来可能会实现。
图形API搜索需要API端点作为
https://graph.facebook.com/search?q=QUERY&type=OBJECT_TYPE
这里可能的对象类型是 - post,event,user,group等。
https://developers.facebook.com/docs/reference/api/search/
返回的值您所看到的是字段和类型状态,照片,链接等都是返回数据中的字段,但您可以通过指定缩小返回的字段
& fields = id,name,picture,type
etc
你可以看到他的文档re可用的搜索类型在以下URL
https://developers.facebook.com/docs/graph-api/using-graph-api
您需要循环浏览结果,并根据需要显示所需的。
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
etcYou 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.
这篇关于Facebook Graph API Filter搜索结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!