Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
844 views
in Technique[技术] by (71.8m points)

php - Facebook Authentication in IE not woking

Im making a facebook canvas app. To get the users info im using the PHP SDK:

 <?

         $app_id = "";
         $secret="";
         $canvas_page = "";
        $auth_url = "";


$facebook = new Facebook(array(
  'appId'  => '',
  'secret' => '',
));

// Get User ID
$user = $facebook->getUser();

if ($user) {
  try {
    // Proceed knowing you have a logged in user who's authenticated.
    $user_profile = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
  }
}

// Login or logout url will be needed depending on current user state.
if ($user) {
  $logoutUrl = $facebook->getLogoutUrl();
} else {
  $loginUrl = $facebook->getLoginUrl();
}

$user = $facebook->api('/me');

?>

Everything works fine in all browsers except on IE (all versions). When I click a link to another page inside the app, i get the next error:

Fatal error: Uncaught OAuthException: An active access token must be used to query
 information about the current user. thrown in 
/hermes/bosoraweb019/b2365/ipg.zicedcom/metrik/fbapp/fb/base_facebook.php on line

The code i just showed is in all pages inside the app, and i only get this problem in IE

Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It seems that for IE you need to enable 3rth party cookies (p3p). Just changed changed the header with php:

<? header('P3P: CP="NOI ADM DEV PSAi NAV OUR STP IND DEM"'); ?>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...