1

I need to access the user's locale, before requesting any permissions from them. This is normally available in getSignedRequest but that appears to be NULL when I view the application directly rather than from within a page tab. So it is NULL when I go to apps.facebook.com/myapp/ but it has the correct values when I view it through a page like www.facebook.com/pages/mypage/pageid?sk=appid. Is this a bug or expected behavior? Do I have to use a different method when I won't be accessing the app through a page?

tshepang
  • 12,111
  • 21
  • 91
  • 136
Baxter
  • 169
  • 4
  • 14

2 Answers2

4

From what I remember, on Facebook, a signed request will only be available on the first page of your tab - eg. index.php.

From here, you'll need to store the retrieved values and access them from local storage or a session as you need them.

Also, if you look at the the application directly it won't be available at all. You have to look at it through Facebook for this method to be available. Unfortunately you'll have to request permissions first if you want this information outside of the page tab.

Good luck!

Darren Craig
  • 462
  • 3
  • 8
  • +1 to this answer (though you can enabled a signed_request on canvas, it's in the app settings) – Igy Feb 13 '12 at 17:35
  • Thanks, yes I changed the app settings! – Baxter Feb 16 '12 at 16:46
  • 1
    Thanks for the Answer and the comments. I had a problem with retrieving the signed request and the solution was to specify the full URL (with index.php). The Page Tab URL: should be https://example.com/index.php not only https://example.com – Yacoub Oweis Jan 31 '13 at 00:53
1

use $_REQUEST["signed_request"] for signed request instead of using function

$dd = parse_signed_request($_REQUEST["signed_request"]);

// function to parse function parse_signed_request($signed_request) { list($encoded_sig, $payload) = explode('.', $signed_request, 2);

    // decode the data
    $sig = base64_url_decode($encoded_sig);
    $data = json_decode(base64_url_decode($payload), true);

    return $data;
}

function base64_url_decode($input)
{
    return base64_decode(strtr($input, '-_', '+/'));
}