Tuesday, January 31, 2017

Facebook graph API locale dependent user info

Facebook graph API locale dependent user info


Sometimes it is necessary to get the data that are already translated to certain language. For example it can be fields such as gender, relationship status, etc. By default, these fields are translated to language that is set in user profile.

The new graph api allows to pass the parameter that points to the language in which the data should be translated.

The example shows how to get my friends info in necessary locale (currently in Danish):
$myFriends = $facebook->api(/me/friends?fields=gender,location,
relationship_status&locale=da_DK);
So, looks simple.

Available link for download