【问题标题】:How does one avoid a cyclic redirect when writing a facebook application using pyfacebook and google app engine?使用 pyfacebook 和 google 应用引擎编写 facebook 应用程序时如何避免循环重定向?
【发布时间】:2010-11-10 02:53:29
【问题描述】:

我正在尝试为 Facebook 编写我的第一个应用程序,使用 python 和 pyfacebook 托管在 Google App Engine 上。我面临的问题是 循环重定向。 Firefox 死了,抱怨“这个页面不是 当我访问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 时看到了这个问题。任何帮助表示赞赏。

【问题讨论】:

  • 发生了哪些重定向?如果我们能看到循环是什么,也许我们就能看到问题所在。

标签: google-app-engine redirect facebook cyclic


【解决方案1】:

如果您刚开始使用 Facebook 应用程序,请考虑使用访问 Graph API 的Official Python SDK。 REST API 是being phased out

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

【讨论】:

    【解决方案2】:

    我同意应付 360。我一直在玩 facebook 应用程序开发有一段时间了。他们似乎经常更改他们的 API,所以你最好使用官方库。

    也就是说,为了回答您的问题,pyfacebbok 尝试从 django 的 HttpRequest.GET 中的信息中获取身份验证信息。这已经过时了,因为 facebook 在 POST 数据中提供了身份验证信息。

    负责的源代码位于pyfacebook/facebook/__init__.py。方法名称似乎是 validate_request

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-03-08
      • 2012-06-07
      • 2011-07-18
      • 1970-01-01
      • 1970-01-01
      • 2012-08-28
      • 2015-05-23
      • 1970-01-01
      相关资源
      最近更新 更多