Facebook FQL user table `sex` field: how to return a man / woman, even the user uses a different language?

Situation:

my facebook application ( http://apps.facebook.com/mymagicmirror/ ), necessary to determine the sex of the user, and then query the opposite gender or male or female

FQL:

SELECT uid, name, pic, sex FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1='.$user_id.') and sex='male' 

Problem: When a facebook user uses a different language, the β€œsex” field no longer matches β€œmen” and β€œwomen”. Instead, say, in Chinese, sex will become η”·ζ€§ / ε₯³ζ€§, and FQL for where sex = 'male' will return zero results.

Any solution to query all male and female friends, even if the facebook user has a language other than English?

+4
php locale facebook-fql
source share
4 answers

Add one of the following functions to the 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 for the en_US locale (from the message in front of it), and the other allows you to go to the locale that you want to use, for example:

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

Then just go to the line 'en_US' for $locale .

+4
source share

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

Just go in English (en_US) to the API call and it should return you sexes in English (male / female).

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

+3
source share

If someone uses the Facebook AS3 API: to solve this problem, pass "locale" as a parameter to get gender information using en_US locale:

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

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

+1
source share

You need to add &locale=en_US to your GET or POST request sent by your client API. For example, if you are using the PHP client library provided by Facebook (the latest version released on November 2), you just need to change the facebookapi_php5_restlib.php file post_request , which starts on line 3316.

Replace line 3320:

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

Wherein:

 $url_with_get = $this->server_addr . '?' . $get_string . '&locale=en_US'; 
0
source share

All Articles