Angeline
Angeline

Reputation: 2379

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->users_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.

Upvotes: 0

Views: 17375

Answers (2)

Joby Joseph
Joby Joseph

Reputation: 2277

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

Upvotes: 0

daaku
daaku

Reputation: 2807

Using the new PHP SDK:

$me = $fb->api('/me');
$locale = $me['locale'];

Upvotes: 2

Related Questions