<blockquote>
<p>Is there a way to use the
javascript SDK to redirect to the
login page rather than loading it as a
popup?</p>
</blockquote>
<p>不。JavaScript SDK将打开一个新窗口,而不是重定向当前窗口。</p>
<p>要向用户显示授权对话框的全屏版本,需要将它们重定向到<code>https://graph.facebook.com/oauth/authorize?client_id={{ application_id }}&redirect_uri={{ redirect_uri }}</code>。请注意,不能从服务器端代码执行此操作,因为这样只会重定向iframe,而Facebook不允许这样做。您需要一个重定向父窗口的中间文档。</p>
<pre><code><!DOCTYPE html>
<!--
This document redirects the parent window to the authorization
dialog automatically, or falls back to a link if the client does not
support JavaScript.
-->
<html>
<head>
<script type="text/javascript">
window.parent.location = 'https://graph.facebook.com/oauth/authorize?client_id={{ application_id }}&redirect_uri={{ redirect_uri }}';
</script>
</head>
<body>
You must <a target="_top" href="https://graph.facebook.com/oauth/authorize?client_id={{ application_id }}&redirect_uri={{ redirect_uri }}">authorize this application</a> in order to proceed.
</body>
</html>
</code></pre>
<p>一旦用户授权了您的应用程序,他或她将被重定向到您在<code>redirect_uri</code>中指定的URI,Facebook将用各种美味的信息(请参阅<a href="http://developers.facebook.com/docs/authentication/canvas" rel="noreferrer">the documentation on signed requests</a>)填充GET参数<code>signed_request</code>,您可以用这些信息代表用户向Facebook发出请求。</p>
<p>请注意,如果计划将此签名请求(或任何其他内容)保存到画布应用程序中的cookie,则需要在标题中设置压缩P3P策略;否则,所有版本的Internet Explorer都将忽略您的cookie。</p>
<p><code>P3P: CP="IDC CURa ADMa OUR IND PHY ONL COM STA"</code></p>
<p>我已经编写了一个库,它使得使用Django开发Facebook画布应用程序变得非常容易,Django为您处理所有这些事情。它名为<a href="https://github.com/jgorset/fandjango" rel="noreferrer">Fandjango</a>,在github上可用。</p>