Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Session Can';不能在IE中进行身份验证_Session_Authentication_Csrf_Explorer_Facebook Authentication - Fatal编程技术网

Session Can';不能在IE中进行身份验证

Session Can';不能在IE中进行身份验证,session,authentication,csrf,explorer,facebook-authentication,Session,Authentication,Csrf,Explorer,Facebook Authentication,我做Facebook开发者已经有一段时间了,但我刚开始使用新的Facebook应用程序布局,并坚持了第一步。很明显,我以前的身份验证方法已经不起作用了 为了解决这个问题,我尝试了一个例子。然而,它在InternetExplorer上似乎根本不起作用 下面是我的代码: <?php $app_id = "-----"; $app_secret = "------"; $my_url = "http://apps.facebook.com/myapp/"; require('facebook-

我做Facebook开发者已经有一段时间了,但我刚开始使用新的Facebook应用程序布局,并坚持了第一步。很明显,我以前的身份验证方法已经不起作用了

为了解决这个问题,我尝试了一个例子。然而,它在InternetExplorer上似乎根本不起作用

下面是我的代码:

<?php 
$app_id = "-----";
$app_secret = "------";
$my_url = "http://apps.facebook.com/myapp/";
require('facebook-php-sdk-2343fca/src/facebook.php');
$facebook = new Facebook(array(
                           'appId'  => $app_id,
                           'secret' => $app_secret,
                           'cookie' => true,));
$session = $facebook->getSession();
session_start();
$code = $_REQUEST["code"];
echo $_REQUEST['state']." == ".$_SESSION['state'];

if(empty($code)) {
    $_SESSION['state'] = md5(uniqid(rand(), TRUE)); //CSRF protection
    $dialog_url = "http://www.facebook.com/dialog/oauth?client_id=" 
       . $app_id . "&redirect_uri=" . urlencode($my_url) . "&state="    
       . $_SESSION['state']  . '&scope=publish_stream,read_stream,user_photos,friends_photos,user_events,friends_events';
    echo("<script> top.location.href='" . $dialog_url . "'</script>");
}

if($_REQUEST['state'] == $_SESSION['state']) {
    $token_url = "https://graph.facebook.com/oauth/access_token?"
    . "client_id=" . $app_id . "&redirect_uri=" . urlencode($my_url)
    . "&client_secret=" . $app_secret . "&code=" . $code;

    $response = file_get_contents($token_url);
    $params = null;
    parse_str($response, $params);

    $graph_url = "https://graph.facebook.com/me?access_token=" 
       . $params['access_token'];

    $user = json_decode(file_get_contents($graph_url));
    //echo("Hello " . $user->name);

//My app goes here!
   } else {
    echo("The state does not match. You may be a victim of CSRF.");
}
?>

到目前为止,我只知道问题与
$\u会话['state']
有关


任何帮助都将不胜感激

嗯,我让它工作了。使用iFrame的Internet Explorer处理P3P cookies是一个相当模糊的问题。简言之,只需将其放在代码开头的某个地方:

header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"'); 页眉('P3P:CP=“IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT”); 您可以在此处阅读更多内容: