Facebook Graph API:对搜索结果进行排序 [英] Facebook Graph API: sorting search results

查看:165
本文介绍了Facebook Graph API:对搜索结果进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Graph API搜索页面,并根据喜欢的次数对搜索结果进行排序.但是显然,没有办法添加任何参数来对搜索结果进行排序,而不是遍历每个页面的点赞次数.

I'd like to search pages using Graph API and sort search results according to the number of likes. But apparently there's no way to add any parameter to sort search results rather than iterating through each page for its number of likes.

我也没有找到有关Graph API的搜索功能如何确定结果顺序的任何信息.如果我使用不同的访问令牌搜索具有相同搜索词(例如,Volkswagen)的页面,则搜索结果的顺序将不同.因此,显然有一个决定搜索结果排序的因素.有人知道默认情况下Graph API如何对搜索结果进行排序吗?

Also I didn't find any information about how Graph API's search function decides order of the results. If I search for a page with same search term (for example, Volkswagen) using different access token, the order of the search results are different. So apparently there's a deciding factor for ordering search results. Does anybody know how Graph API sorts search results by default?

推荐答案

该API不为大多数端点提供排序.

The API doesn’t offer sorting for most endpoints.

不过,您可以通过使用字段扩展来获得同一请求中返回的页面的粉丝计数:

You can get the fan count for the returned pages within the same request though, by using field expansion:

/search?type=page&q=blah&fields=id,name,fan_count

–然后您可以使用它来进行最终排序.使您不必提出额外的请求-但取决于您搜索返回的页面数(此处为分页的页面,而不是FB页面),在进行排序之前,您可能需要先提取所有页面.

– then you can use that to do the sorting on your end. Spares you from having to make extra requests - but depending on how many pages your search returns (pages as in pagination here, not FB pages), you might need to fetch all of them before you do the sorting.

我也没有找到有关Graph API的搜索功能如何确定结果顺序的任何信息.如果我使用不同的访问令牌搜索具有相同搜索词(例如Volkswagen)的页面,则搜索结果的顺序将不同.

Also I didn't find any information about how Graph API's search function decides order of the results. If I search for a page with same search term (for example, Volkswagen) using different access token, the order of the search results are different.

使用用户访问令牌时,搜索结果将根据令牌所属的特定用户量身定制.

When you use a user access token, then the search results are tailored to the specific user the token belongs to.

您还可以使用您的应用访问令牌来执行此搜索-但是您将仅获得不受任何访问限制的公共页面.如果您使用用户访问令牌,那么它将考虑特定用户可以看到哪些非公开页面.

You can also use your app access token to perform this search - but then you will only get public pages that are not access-restricted in any way. If you use a user access token, then it will take into account which non-public pages that specific user can see.

这篇关于Facebook Graph API:对搜索结果进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆