【问题标题】:Facebook Iframe App - Strange Redirection ProblemsFacebook iframe 应用程序 - 奇怪的重定向问题
【发布时间】:2010-08-09 09:42:54
【问题描述】:

当我在 Facebook iframe 应用程序中执行服务器端重定向时,我得到了这个带有链接的奇怪 Facebook 徽标。当我单击它时,我会被重定向到我首先将重定向设置为的站点。这里会发生什么?有任何“点击保护”吗?

谢谢!

重定向代码:
试过客户端重定向

    args = dict(client_id=FACEBOOK_APP_ID, redirect_uri=base_dir , scope='user_photos,email,offline_access')
    return render_to_response('fb/nopermission.html', { 'javascript': "<script>window.top.location=\"" + "https://graph.facebook.com/oauth/authorize?" + urllib.urlencode(args )+ "\"</script>"  } )

服务器重定向:

args = dict(client_id=FACEBOOK_APP_ID, redirect_uri=base_dir , scope='user_photos,email,offline_access')
return HttpResponseRedirect(https://graph.facebook.com/oauth/authorize?" + urllib.urlencode(args))

两种情况的结果相同

【问题讨论】:

  • 您要重定向到的 URL 是什么?
  • @serg555 如您所见...已经尝试过了! ://
  • @Henrik 所以当你做 js 重定向时,你的页面 url 看起来如何(在浏览器中)?
  • 两种方法(客户端和服务器)的结果相同(屏幕截图)。

标签: authentication facebook iframe


【解决方案1】:

啊! Facebook 的文档如此糟糕,以至于我在为它开发时遇到了无数问题。

这是因为您无法直接从您的应用重定向。使用 href 链接并将目标属性指定为 _top 或使用 javascript

window.top.location="redirecturl"

解决此错误。

【讨论】:

    【解决方案2】:

    出于重定向目的,请使用以下代码:

    <html><head>
    <script type="text/javascript">
      window.top.location.href = "<?php echo $loginUrl; ?>";
    </script>
    <noscript>
      <meta http-equiv="refresh" content="0;url=<?php echo $loginUrl; ?>" />
      <meta http-equiv="window-target" content="_top" />
    </noscript>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-27
      • 2011-06-27
      • 2013-12-17
      • 2011-08-05
      • 2015-12-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多