I’ve looked around so if this is a re-post, send me in the right direction but I keep getting 1 single random character when I run this. What am I doing wrong? I just want to output the user ID.
<?php require 'facebook.php';
$facebook = new Facebook( array(
'appId' => "XXXXXXXXXXXXXXXXXXX",
'secret' => "XXXXXXXXXXXXXXXXXXXXXXX",
'cookie' => true
) );
try {
$me = $facebook->api('/me');
} catch ( FacebookApiException $e ) {
error_log( $e );
}
$signed_request = $_REQUEST["signed_request"];
$user_id = $signed_request['user_id'];
echo $user_id;
$signed_request = $facebook->getSignedRequest();
$liked = $signed_request['page']['liked'];
?>
Also the $signed_request[‘page’][‘liked’] works just fine.
Is that a copy/paste from your code?
If so
won’t work, it’s not the correct signed_request and it won’t be readable because you haven’t decrypted the response (in the PHP SDK the decryption is automatic in the ‘getSignedRequest()’ function)
The page code you have is correct, so to get the current user ID, assuming that the user has accepted the auth dialog for your app, the code should be