According to Facebook - authentication in the Canvas Page Document , they say what we get signed_request, which consists of a JSON object. Now they say that it signed_requestcan go through. $_POST['signed_request']I agree that it works for me.
Now, according to them, if the user is registered, I get the value of the JSON object as follows: -
{
"expires":UNIXTIME_WHEN_ACCESS_TOKEN_EXPIRES,
"algorithm":"HMAC-SHA256",
"issued_at":UNIXTIME_WHEN_REQUEST_WAS_ISSUED,
"oauth_token":"USER_ACCESS_TOKEN",
"user_id":"USER_ID",
"user":{
"country":"ISO_COUNTRY_CODE",
"locale":"ISO_LOCALE_CODE",
...
}
}
Now I want to extract user_idfrom this, so I use this piece of code, but it does not work: -
if(isset($_POST['signed_request']))
{
echo 'YES';
$json = $_POST['signed_request'];
$obj = json_decode($json);
print $obj->{'user_id'};
}
Just type it YES. Why is this so?
- , user_id, facebook , 4-. , - , . .