Facebook FQL user table `sex` field : how to return male/female even the user is using different locale?

故事扮演 提交于 2019-12-03 03:52:13
ma11hew28

Add one of the following functions to your facebookapi_php5_restlib.php file:

Function for users.getInfo:
from: http://forum.developers.facebook.com/viewtopic.php?pid=166745#p166745

public function &users_getInfo_en_US($uids, $fields) {
  return $this->call_method('facebook.users.getInfo',
    array('uids' => $uids, 'fields' => $fields, 'locale' => 'en_US'));
}

Then, you can call users_getInfo_en_US($user, array('sex'));


Functions for FQL:
from the link above but with pid=166866#p166866
One is for the en_US locale (from the post before it) and the other lets you pass in the locale you want to use, like so:

public function &fql_query_localized($query, $locale) 
{
  return $this->call_method('facebook.fql.query',
    array('query' => $query, 'locale' => $locale));
}

Then, just pass in the string 'en_US' for $locale.

From http://forum.developers.facebook.com/viewtopic.php?pid=174065 :

Just pass english locale (en_US) to the API call and it should return you genders in english (male/female).

You may also find http://forum.developers.facebook.com/viewtopic.php?pid=166744 useful.

In case someone's using Facebook AS3 API: to work out this issue, pass the "locale" as param to get gender info using en_US locale:

Facebook.api("/me",getMeHandler, {locale:'en_US'});

This will return english "male"/"female" values, not localized ones.

You need to add &locale=en_US to your GET or POST request being sent by your API client. For example, if you are using the PHP client library provided by Facebook (the latest version released Nov. 2), then you simply need to modify the facebookapi_php5_restlib.php file's post_request function which begins on line 3316.

Replace line 3320:

$url_with_get = $this->server_addr . '?' . $get_string;

With this:

$url_with_get = $this->server_addr . '?' . $get_string . '&locale=en_US';
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!