FB应用程序中的Facebook API调用需要登录(仅在IE中) [英] Facebook API call inside FB Application requires login (just in IE)

查看:124
本文介绍了FB应用程序中的Facebook API调用需要登录(仅在IE中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一个FB应用程序,显示即将发生的公共页面事件。我使用以下javascript:

 < script src =https://connect.facebook.net/en_US/all。 JS>< /脚本> 
...
FB.init({
appId:{APP_ID},
status:true,//检查登录状态$ b $ cookie:true,// enable cookies允许服务器访问会话
xfbml:true //解析XFBML
});

FB.api('/ {page_id} / events?since = today',function(response){
...
});

代码在Chrome和Firefox中运行良好(尽管只是上传到服务器并在FB内部执行https://apps.facebook.com/{app_name}/),而不是本地或直接从托管服务器调用),但在IE中运行时,我得到这个错误:

< pre $ {
error:{
type:OAuthAccessTokenException,
message:请求访问令牌资源。


$ / code $ / pre

我看不到用户必须登录的原因,反正这个app已经在FB里面运行了。任何想法?



感谢
simon

解决方案

Facebook应用程序在iframe中运行,您应该设置p3p策略以让ie运行,
将此代码放入Global.asax(假设您在asp.net上):

  protected void Application_BeginRequest(Object sender,EventArgs e)
{

HttpContext.Current.Response.AddHeader(p3p, CP = \CAO PSA OUR \);

}


i made a FB application that shows the upcoming events of a public page. i use the following javascript:

<script src="https://connect.facebook.net/en_US/all.js"></script>
...
FB.init({
    appId  : {APP_ID},
    status : true, // check login status
    cookie : true, // enable cookies to allow the server to access the session
    xfbml  : true  // parse XFBML
});

FB.api('/{page_id}/events?since=today', function(response) {
    ...
});

the code runs fine in chrome and firefox (although just when uploaded to a server and executed inside FB (https://apps.facebook.com/{app_name}/), not local or when called direct from the hosting server) but when run in IE i get this error:

{
   "error": {
      "type": "OAuthAccessTokenException",
      "message": "An access token is required to request this resource."
   }
}

i dont see why the user has to login, since the app anyways already runs inside FB. any ideas?

thanks simon

解决方案

As facebook app runs in iframe you should set up p3p policy in order to let ie runs, put this code in to your Global.asax (assuming you are on asp.net):

protected void Application_BeginRequest(Object sender, EventArgs e)
{

    HttpContext.Current.Response.AddHeader("p3p", "CP=\"CAO PSA OUR\"");

}

这篇关于FB应用程序中的Facebook API调用需要登录(仅在IE中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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