Facebook应用程序,ie浏览器的未捕获oautheexception

Facebook apps, Uncaught OAuthException on Internet Explorer

本文关键字:oautheexception 浏览器 应用程序 ie Facebook      更新时间:2023-09-26

我在Internet Explorer上使用Facebook应用程序有一个问题。在其他浏览器上它正常工作,但在IE上我得到错误:

致命错误:Uncaught oautheexception:必须使用活动访问令牌来查询当前用户的信息。在/base_facebook.php第1340行抛出

我找到了与这个错误的联系。在我的代码 行中
$userinfo = $facebook->api('/me');

Hire is my code:

<?php
session_start();
header('Content-Type: text/html; charset=UTF-8');
require 'facebook.php';
// APPS INICIALIZATION
$appid = '123APPID123';
$facebook = new Facebook(array(
  'appId'  => $appid,
  'secret' => '123SECRETID123',
  'cookie' => true,
));
// END - APPS INICIALIZATION
?>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/0.10.0/lodash.min.js"></script>
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<script src="https://connect.facebook.net/en_US/all.js"></script>
<div id="fb-root"></div>
<script>
    window.fbAsyncInit = function() {
        FB.init({
              appId      : '123APPID123', // App ID
              status     : true, // check login status
              cookie     : true, // enable cookies to allow the server to access the session
              xfbml      : true  // parse XFBML
        });
    };
    (function(d){
        var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
        if (d.getElementById(id)) {return;}
        js = d.createElement('script'); js.id = id; js.async = true;
        js.src = "//connect.facebook.net/en_US/all.js";
        ref.parentNode.insertBefore(js, ref);
    }(document));
</script>
<br>
<?php 
// RETRIVAL DATA AND OTHERS INFO
$userid = $facebook->getUser();
$userinfo = $facebook->api('/me');
// END - RETRIVAL DATA AND OTHERS INFO
// PUT DATA TO VARIABLE
$email = $userinfo['email'];
$first_name = $userinfo['first_name'];
$last_name = $userinfo['last_name'];
// DATA TESTER //
echo $email.'<br>';
echo $first_name.'<br>';
echo $last_name.'<br>';
?>

你知道吗?

对于所有在IE和facebook授权方面有同样问题的人。此问题与$facebook->api('/me')无关;或facebook -> getUser ();. 您可以使用

来检查它。
print_r($facebook->getUser());

如果你得到0的答案,这意味着IE不发送所有的cookie到你的PHP脚本。你应该在start PHP file之后用这一行开始你的PHP代码:

header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');

现在IE发送所有cookie没有任何问题