在使用pyfacebook和谷歌应用引擎编写Facebook应用程序时,如何避免循环重定向? [英] How does one avoid a cyclic redirect when writing a facebook application using pyfacebook and google app engine?

查看:126
本文介绍了在使用pyfacebook和谷歌应用引擎编写Facebook应用程序时,如何避免循环重定向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用在Google App Engine上托管的
python和pyfacebook,为Facebook写第一个应用程序。我面临的问题是
循环重定向。当我访问 http://apps.facebook时,Firefox死亡抱怨此页面不是
重定向正确 .com / appname

I'm trying to write my first application for Facebook using python and pyfacebook hosted on Google App Engine. The problem I'm facing is that of cyclic redirects. Firefox dies complaining "This page isn't redirecting properly" when I visit http://apps.facebook.com/appname.

这是代码:

class CanvasHandler(webapp.RequestHandler):
    def get(self):
        ## instantiate the Facebook API wrapper with your FB App's keys
        fb = facebook.Facebook(config.FACEBOOK_API_KEY, config.FACEBOOK_API_SECRET)

        ## check that the user is logged into FB and has added the app
        ## otherwise redirect to where the user can login and install
        if fb.check_session(self.request) and fb.added:
            pass
        else:
           url = fb.get_add_url()
           self.response.out.write('<script language="javascript">top.location.href="' + url + '";</script>')
           return

        rendered_template = render_template('facebook/app.html')
        self.response.out.write(rendered_template)

当我退出Facebook时,我看到这个问题。任何帮助是赞赏。

I see this problem when I'm logged out of Facebook. Any help is appreciated.

推荐答案

如果您刚刚开始使用您的Facebook应用程序,请考虑使用官方Python SDK ,它访问Graph API。 REST API是被淘汰

If you're just starting out with your Facebook app, consider using the Official Python SDK which accesses the Graph API. The REST API is being phased out.

要进行身份验证,请使用 JS SDK 将设置您可以在服务器端读取的cookie。

To do authentication, use the JS SDK which will set a cookie you can read on the server side.

这篇关于在使用pyfacebook和谷歌应用引擎编写Facebook应用程序时,如何避免循环重定向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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