Tuesday 22 March 2011

Facebook fan page: pass parameter to the application via url

Some times while developing the application as page tab it is necessary to pass some parameters to the application. For example it is needed to determine what the page is requested or stuff like that. The Facebook documentation contains the description of the parameter app_data which can help to do it.

This parameter is a JSON string and is usually specified when the application needs to pass some data to itself. The example of the usage:
http://www.facebook.com/somedummypage?sk=app_xxsome
appcodexx&app_data=somedata
If this parameter is specified in url of the page tab on the server side of the application it will be available as a part of signed_request ($_REQUEST['signed_request']). So, in the example above this parameter will be available as $_REQUEST['signed_request']['app_data'].

Sunday 20 March 2011

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.