I have implemented a Facebook connect example with my Codeigniter website. I am trying to bring the Facebook connect code up to date but I cannot work out how to parse the fbsr_cookie which has replaced the fbs_cookie.
I have the following code –
function get_facebook_cookie()
{
// get the fb app id, and secret from CI config source
$CI =& get_instance();
$app_id = $CI->config->item('facebook_app_id');
$application_secret = $CI->config->item('facebook_app_secret');
if(isset($_COOKIE['fbs_' . $app_id])){
$args = array();
parse_str(trim($_COOKIE['fbs_' . $app_id], '\\"'), $args);
ksort($args);
$payload = '';
foreach ($args as $key => $value) {
if ($key != 'sig') {
$payload .= $key . '=' . $value;
}
}
if (md5($payload . $application_secret) != $args['sig']) {
return null;
}
return $args;
}
else{
return null;
}
}
and then to get the user’s Facebook id –
function getUser()
{
$cookie = $this->get_facebook_cookie();
$user = @json_decode(file_get_contents( 'https://graph.facebook.com/me?access_token=' . $cookie['access_token']), true);
return $user;
}
Does anyone have an idea how I can change this to work with the fbsr_cookie?
Thanks.
The new cookie format with name
fbsr_APPIDis actually asigned_requestwhich is quite easy to parse and documentation showing exactly how to do this (see “Verifying and Decoding” insigned_requestDocumentation