2

Code:

$facebook = new Facebook(array(
                'appId' => some_fb_app_id),
                'secret' => some_fb_app_secret),
                'cookie' => true,
            ));
$result = $facebook->getSignedRequest();
echo var_export($result,1);

Result:

array (
  'algorithm' => 'HMAC-SHA256',
  'code' => 'A.....l',
  'issued_at' => 1354720771,
  'user_id' => 'some_user_id',
)

I expect $result["user"]["country"] to be set. How can I fix this problem?

ps. by Facebook Graph API - how to get user country?

Community
  • 1
  • 1
  • It's customary to show you've put in some effort to solve your problem. Have you taken a look at the Facebook PHP SDK? I.e. http://developers.facebook.com/docs/howtos/login/signed-request/ – mtsr Dec 05 '12 at 16:10

1 Answers1

0

According to the facebook PHP SDK getSignedRequest() only gives you the signed request, just like the name suggests. User info is usually gotten through the Graph API, using calls like

$facebook->api('/me','GET');

which gives you the profile for the user associated with the access_token you are using.

Note that you will only ever get information that you have the permissions for, so if you haven't added a particular bit of info beyond the basics to your apps scope, you will not get it.

mtsr
  • 3,092
  • 1
  • 14
  • 21
  • Using `$facebook->api('/me','GET');` I could receive 'location' `array ( 'id' => '106045326100801', 'name' => 'Dnipropetrovsk, Ukraine', ),` But 'name' is just a location name - country is not strictly provided. Using 106045326100801 I could retrieve detailed location info - but country isn't strictly provided too. – Vladimir Malyk Dec 05 '12 at 16:43