How to get the locale or current location of the user in facebook iframe application?
I am developing an iFrame application in facebook. What is the syntax to get the locale of an user? I am using the PHP client library.
I had tried this piece of code:
<?php
$user_details = $facebook->api_client->use开发者_如何学Crs_getInfo($user_id, 'name,hometown_location');
$locale = $user_details[0]['hometown_location']['city'];
echo "Location: ".$locale;
?>
But I get the following error msg:
Fatal error: Cannot use string offset as an array in C:\xampplite\htdocs\FacebookApp\deals.php on line 51
Some one help me with this.
Using the new PHP SDK:
$me = $fb->api('/me');
$locale = $me['locale'];
One can find locale of a user either using graph api or FQL.
When using graph api, graph url will be
https://graph.facebook.com/[userid]
if its FQL the fql query will be:
select locale from user where uid = [userid]
You can a detail explanation and demo here: http://bit.ly/AfMS2E
精彩评论