Created
April 20, 2011 19:31
-
-
Save chrismendis/932450 to your computer and use it in GitHub Desktop.
Returns a JSON object containing the signed request that Facebook sends to your FB app as a POST variable.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$req = htmlspecialchars($_POST['signed_request']); | |
$reqParts = split('\.', $req); | |
$encodedValue = $reqParts[1]; | |
$encodedValue = preg_replace('/\+/', '-', $encodedValue); | |
$encodedValue = preg_replace('/\//', '_', $encodedValue); | |
$pad = strlen($encodedValue) % 4; | |
if ($pad > 0) { | |
$pad = 4 - $pad; | |
} | |
$encodedValue = str_pad($encodedValue, $pad, '='); | |
$result = json_decode(base64_decode($encodedValue)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment