简体   繁体   English

Facebook Graph API非英语搜索查询

[英]Facebook Graph API Non English Search Queries

I've been trying to use facebook graph api public search. 我一直在尝试使用Facebook图形API公共搜索。 It works just fine for english search queries, for example, http://graph.facebook.com/search?q=watermelon%20&type=post 对于英语搜索查询来说,它工作得很好,例如, http://graph.facebook.com/search?q=watermelon%20&type=post

On the other hand, while setting a non english search result, I'm also receiving only english results, but non of the results in a result in the language of the search query. 另一方面,在设置非英语搜索结果时,我也仅接收英语结果,但未接收到以搜索查询语言显示的结果。

For example, http://graph.facebook.com/search?q=ביבי&type=post 例如, http://graph.facebook.com/search?q=ביבי&type = post

Does not return any relevant result (the search query is "ביבי" , a word in Hebrew. None of the returned results are in Hebrew). 不返回任何相关结果(搜索查询为“ביבי”,希伯来语中的单词。返回的结果均不在希伯来语中)。

What could I do to fix it ? 我该如何解决?

Any suggestion will be helpful. 任何建议都会有所帮助。

Thanks in advance. 提前致谢。

To receive response in a locale which is different from your computer default locale, you should specify it with the request. 要在与计算机默认语言环境不同的语言环境中接收响应,应在请求中指定它。 Right now there are 2 ways to do that: 现在有两种方法可以做到这一点:

  1. use &locale=he_IL in the URL ( list of Facebook locales ), eg 在URL( Facebook语言环境列表 )中使用&locale=he_IL ,例如

    https://graph.facebook.com/search?q=YOUR_QUERY&type=post&fields=message&locale=he_IL https://graph.facebook.com/search?q=YOUR_QUERY&type=post&fields=message&locale=he_IL

  2. use Accept-Language header with your request, eg 在请求中使用Accept-Language标头,例如

    'Accept-Language': 'he_IL,he,iw;q=0.9'

Recently, the first approach had a bug (now it works well), so I would use both of them (the first one will have more priority then another). 最近,第一种方法存在一个错误(现在可以正常使用),因此我将同时使用它们(第一种方法的优先级高于其他方法)。

Note: Search across the specified locale will return posts available in this locale. 注意:在指定的语言环境中进行搜索将返回该语言环境中可用的帖子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM