带有Internet Explorer的永久重新加载页面 [英] Eternal reloading page with Internet Explorer

查看:170
本文介绍了带有Internet Explorer的永久重新加载页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Internet Explorer 7的FB应用程序出现问题.

I've got a problem with my FB apps with Internet Explorer 7.

我正在使用FB之前提供的这段代码:

I'm using this piece of code, provided by FB some time ago :

$auth_url = "http://www.facebook.com/dialog/oauth?client_id=" 
        . FACEBOOK_APP_ID . "&redirect_uri=" . urlencode(CANVAS_PAGE . 'index.php') . "&scope=user_likes,publish_stream";

$signed_request = $_REQUEST["signed_request"];

list($encoded_sig, $payload) = explode('.', $signed_request, 2); 

$data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);

// If first time we use the application -> ask for permissions
if (empty($data["user_id"]))
{
    echo("<script> top.location.href='" . $auth_url . "'</script>");
}   
// else display the page code
else
{
    }

使用此代码,页面可以正确加载,但是在1秒钟后,页面将重新加载,依此类推,因此无法使用.

Using this code, the page loads correctly but then, after 1 second, it reloads and so on, so it gets impossible to use.

通过取消注释行

    echo("<script> top.location.href='" . $auth_url . "'</script>");

问题已解决(顺便说一句,在我的情况下,代码不应执行此行...奇怪的是,取消注释未使用的代码行可以解决我的问题,但是无论如何...)

the problem is solved (btw, in my case, the code should not execute this line... It is SO strange that uncommenting a non-used line of code solves my problem but anyway...)

在阅读了一些论坛之后,我有一个印象,即此问题是与P3P标头相关的一个问题.因此,我尝试添加此行:

After reading some forums, I had the impression that this issue was a P3P header related one. So I tried to add this line:

header('P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"');

在body标签之后.我还尝试将它添加到body标签之前,最后我尝试将其添加为meta标签:

after the body tag. I also tried to add it just before the body tag, and I finally tried to add it as a meta tag:

<meta http-equiv="P3P" content='CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM CURa ADMa PHY ONL COM STA"'>

但是这3个选项都不适合我,并且我的应用仍然可以永久加载.

but none of these 3 options worked for me, and my app still loads eternally.

有人知道吗?

提前谢谢!

好吧,我读了一些有关同一问题的论坛:

Well, I read some forums relating the same problem :

  • http://facebook.stackoverflow.com/questions/5808187/facebook-app-loads-fine-in-firefox-but-keeps-reloading-in-internet-explorer-7-8
  • http://facebook.stackoverflow.com/questions/5986373/facebook-app-canvas-page-keeps-refreshing-on-internet-explorer-ie7

但是这些解决方案都不适合我,我仍然遇到这个永恒的重新加载页面问题.

but none of these solutions worked for me, I still have this eternal reloading page problem.

我还阅读了一个我认为可以解决我的问题的论坛- http://adamyoung.net/IE-Blocking-iFrame-Cookies -但还是. ..没有运气.

I also read a forum which I thought would solve my problem - http://adamyoung.net/IE-Blocking-iFrame-Cookies - but again... no luck.

有人可以帮助我吗?

推荐答案

也无法使您的代码正常工作,只是重新加载了代码.似乎从未设置$ _REQUEST ["signed_request"].

Couldn't get you code to work either, it just reloaded. Seems $_REQUEST["signed_request"] was never set.

但是我使用它来处理 http://developers.facebook.com/中的代码docs/authentication/

   <?php
   $app_id = "your app id";
   $app_secret = "your app secret";
   $my_url = "your app url";

   session_start();
   $code = $_REQUEST["code"];

   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'];

     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);
   }
   else {
     echo("The state does not match. You may be a victim of CSRF.");
   }

也就是说,我建议您使用Facebook PHP SDK,> http://developers.facebook.com/docs/reference/php/使Facebook应用程序的编程变得更加容易.

That said, I would recommend you to use the Facebook PHP SDK, http://developers.facebook.com/docs/reference/php/ that makes programming facebook apps easier.

要使用PHP SDK进行身份验证,您可以执行以下操作:

To authenticate with the PHP SDK, you would do something like the following:

// update this to where you've stored the facebook PHP SDK
require '../src/facebook.php';

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

$user = $facebook->getUser();
if ($user) {
  print "You've logged in!";
} else {
  echo("<script> top.location.href='" . $facebook->getLoginUrl() . "'</script>");
}

标题

此外,请尝试在代码的第一行中对此进行设置:

headers

Also, try setting this in the first lines of you code:

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

当fb会话有时在应用程序中丢失时,这对我有帮助.在这篇文章中发现: 如何正确处理会话和使用Facebook PHP SDK 3.0访问令牌?

This helped me when the fb session was lost sometimes in an app. Found that in this post: How to properly handle session and access token with Facebook PHP SDK 3.0?

这篇关于带有Internet Explorer的永久重新加载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆