Facebook应用适用于所有浏览器,但不适用于IE8 [英] Facebook app works on all browsers but not IE8

查看:684
本文介绍了Facebook应用适用于所有浏览器,但不适用于IE8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个Facebook应用程序。在大多数浏览器上,应用程序工作正常(我在FF,chrome和safari测试了它,并且它们都可以正常运行)。然而,当我在IE8上测试时,当尝试对其中一个页面进行ajax调用时,我收到此错误消息:

 致命错误:未捕获异常:102:需要在
/home1/website/public_html/facebook/src/facebook.php第515行引发用户会话

这是比 facebook.php 中包含第515行的功能:

  protected function _restserver($ params){
//通用应用程序级别参数
$ params ['api_key'] = $这 - > getAppId();
$ params ['format'] ='json-strings';

$ result = json_decode($ this-> _oauthRequest(
$ this-> getApiUrl($ params ['method']),
$ params
),true);

//返回结果,抛出错误
if(is_array($ result)&& isset($ result ['error_code'])){
throw new FacebookApiException($结果);
}
return $ result;
}

我的猜测是,会议或IE8设置但我不知道如何解决这个问题。

解决方案

尝试将这个标题添加到您的php文件之上:

 <?php 
header('p3p:CP =NOI ADM DEV PSAi COM NAV我们的OTR STP IND DEM );
?>

这将使跨域AJAX调用工作在IE



编辑:



实际上,长的正确答案如下:



当开发一个IFrame Canvas应用程序(或来自不同域名的页面中托管的任何其他iframe)访问cookies(被称为第三方Cookie)在某些情况下被限制(默认IE配置)。 Firefox,Chrome,Safari,Opera都按预期工作,但IE阻止访问此Cookie。此标题的存在(称为 P3P紧凑隐私政策)将使IE接受Cookie来自不同的域名。



这是如何使您的会话代码工作?



在服务器中,页面发出存储在客户端的会话cookie。如果您的iframe使用会话,那么浏览器必须允许它存储cookie。



下载存储cookie意味着会话将丢失,您的会话代码将失败,就像你已经发布。



希望这有帮助。



PS:BTW我不知道什么p3p标题中的所有奇怪的首字母缩略词意味着。我看到很多变化的工作,所以你应该尝试调查一下更多关于它


I am devloping a facebook app. Stragnly, the app work fine on most browsers (I tested it on FF, chrome and safari and it worked fine on all of them). However when I tested on IE8, I received this error message when trying to make an ajax call to one of the pages:

Fatal error: Uncaught Exception: 102: Requires user session thrown in
/home1/website/public_html/facebook/src/facebook.php on line 515

This is the function than contain line 515 in facebook.php:

protected function _restserver($params) {
  // generic application level parameters
  $params['api_key'] = $this->getAppId();
  $params['format'] = 'json-strings';

  $result = json_decode($this->_oauthRequest(
    $this->getApiUrl($params['method']),
    $params
  ), true);

  // results are returned, errors are thrown
  if (is_array($result) && isset($result['error_code'])) {
    throw new FacebookApiException($result);
  }
  return $result;
}

My guess is that it is something to do either with sessions or with IE8 settings but I am not sure how to fix this issue.

解决方案

Try adding this header on top of your php file:

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

This will make cross-domain AJAX calls work in IE

EDIT:

Actually the long correct answer is the following:

When developing an IFrame Canvas app (or any other iframe hosted in a page from a diferent domain) access to cookies (known as 3rd party cookies) are restricted under some conditions (Default IE config). Firefox, Chrome, Safari, Opera all work as expected but IE block access to this cookies. The presence of this header (Which is called a P3P Compact Privacy Policy) will make IE to accept cookies from diferent domains.

And how this makes your session code work???

Well to mantain session information in the server, the page issues a session cookie which is stored in the client. If your iframe uses session then it has to be allowed by the browser to store the cookie.

Falling to store the cookie means the session will get lost and your session-based code will fail like you have posted.

Hope this helps.

PS: BTW I have no idea what all the strange acronyms in the p3p header means. I have seen many variations of it working so you should try to investigate a little bit more about it

这篇关于Facebook应用适用于所有浏览器,但不适用于IE8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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