Reputation: 1454
I want to know how i can access to my app data (title and description) when the user has access to it and get the localized values using the user locale.
My code is this:
var imageUrl = "http://mysite.test/webroot/img/test_image.jpg",
userID = response.authResponse.userID,
userLanguage,
appTitle,
appDescription;
if (response.status === 'connected') {
FB.api(
"/" + userID,
function (response) {
if (response && !response.error) {
userLanguage = response.locale;
}
}
);
FB.api(
'me/{namespace}:{action}', 'post',
{
object: {
"url": imageUrl,
"title": appTitle,
"description": appDescription,
"image": imageUrl
}
},
function(response) {
}
);
} else if (response.status === 'not_authorized') {
FB.login( function( response ) {
}, {scope: "publish_actions"} );
} else {
FB.login( function( response ) {
}, {scope: "public_profile"} );
}
I tried to use this code, but the /me
node returns the user data and i want to get the app data:
FB.api(
"/me",
function (response) {
if (response && !response.error) {
/* handle the result */
}
}
);
Upvotes: 0
Views: 62
Reputation: 31479
You can get the User's locale with
/me?fields=id,locale
Then you can use this locale
in the second call for the app:
/{app_id}?fields=id,name,description&locale={locale}
should work. You need to know the app id and replace {app_id}
with it. The locale
parameter defines the locale for which you want to receive the data in.
Please be aware that it's not necessarily content in every locale available...
The list of locales can be found at https://www.facebook.com/translations/FacebookLocales.xml
See
Upvotes: 1