English 中文(简体)
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:xampplitehtdocsFacebookAppdeals.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





相关问题
Facebook Connect login dialog not working

I am using Facebook Connect for iPhone and following the official instructions. I use the following code to display the login dialog: FBLoginDialog* dialog = [[[FBLoginDialog alloc] initWithSession:...

Facebook App Profile Tab is Empty ... No Content Displayed?

I can view my application via the http://apps.facebook.com/myapplication/ link and the content shows up correctly. I also added the application as a tab to a facebook page. However, when viewing the ...

Facebook Platform error: "Object cannot be liked"

I m working on a Facebook Application that generates wall posts. In testing these posts, I ve discovered that the Facebook Platform action of "liking" a post is failing. The specific error message ...

how to call showPermissionsDialog() in php (facebook api)?

I was reading over the documentation yet I could not figure out how to call Facebook.showPermissionsDialog() in php include_once ./facebook-platform/php/facebook.php ; $facebook = new Facebook(my ...

Facebook connect

If I plug in the facebook connect into my website, How can I prevent double signups? Lets say I have a user that s already signed up to my site but he clicked the connect with facebook, is there a ...

热门标签