FB 应用程序内的 Facebook API 调用需要登录(仅在 IE 中)

问题描述 投票:0回答:1

我制作了一个 FB 应用程序,用于显示公共页面即将发生的事件。我使用以下 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) {
    ...
});

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

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

我不明白为什么用户必须登录,因为该应用程序已经在 FB 内运行。有什么想法吗?

谢谢 西蒙

javascript html facebook facebook-opengraph
1个回答
0
投票

当 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\"");

}
© www.soinside.com 2019 - 2024. All rights reserved.