app-engine-patch 和 pyFacebook 不工作

发布于 2024-08-17 02:23:17 字数 1681 浏览 4 评论 0原文

我正在尝试使用 app-engine-patch 和 pyFacebook 编写一个 Facebook 应用程序。 我只使用每个工具提供的示例,但由于某种原因它不起作用。

我已经按照此处接受的答案中的描述将两者结合起来: Facebook、Django 和 Google App Engine

app-engine-patch 似乎可以工作很好,但是当我尝试使用 @facebook.require_login() 时,我从 GAE 的日志中得到以下信息:

Exception in request:
Traceback (most recent call last):
  File "/base/data/home/apps/app-name/1.339079629847560090/common/zip-packages/django-1.1.zip/django/core/handlers/base.py", line 92, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/base/data/home/apps/app-name/1.339079629847560090/facebook/djangofb/__init__.py", line 87, in newview
    if not fb.check_session(request):
  File "/base/data/home/apps/app-name/1.339079629847560090/facebook/__init__.py", line 1293, in check_session
    self.session_key_expires = int(params['expires'])
ValueError: invalid literal for int() with base 10: 'None'

无论我用 @facebook.require_login() 装饰哪个视图,都会发生这种情况,

我正在使用两个项目的最新版本,我不知道为什么它不会起作用。

非常感谢您抽出时间。

更新:我为 pyFacebook 做了一个快速修复,但我只是忘记将它放回线程中。

现在也作为答案,因为这似乎是唯一的方法。

如果您将 facebook/__init__.py 第 1292+ 行从以下位置更改

    if params.get('expires'):
        self.session_key_expires = int(params['expires'])

    if params.get('expires'):
        if params['expires'] == 'None':
            params['expires'] = 0   
        self.session_key_expires = int(params['expires'])

:它将起作用,但它是一个 hack,也许它可以做得更优雅,但它确实有效。 必须向 pyFacebook 开发人员指出这个线程,也许他们会有更好的解决方案。

I am trying to write a facebook app using app-engine-patch and pyFacebook.
I am using nothing but the examples provided with each tool and for some reason it will not work.

I have combined the two just as described in the accepted answet here:
Facebook, Django, and Google App Engine

app-engine-patch seems to work just fine but when I try to use @facebook.require_login() I get this from GAE's logs:

Exception in request:
Traceback (most recent call last):
  File "/base/data/home/apps/app-name/1.339079629847560090/common/zip-packages/django-1.1.zip/django/core/handlers/base.py", line 92, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/base/data/home/apps/app-name/1.339079629847560090/facebook/djangofb/__init__.py", line 87, in newview
    if not fb.check_session(request):
  File "/base/data/home/apps/app-name/1.339079629847560090/facebook/__init__.py", line 1293, in check_session
    self.session_key_expires = int(params['expires'])
ValueError: invalid literal for int() with base 10: 'None'

This happends no matter which view I decorate with @facebook.require_login()

I am using the latest from both projects and I have no idea why it wont work.

Many thanks for your time.

UPDATE: I made a quickfix for pyFacebook, but I just forgot to put it back in the thread.

Now also as an answer, since it seems to be the only way.

If you change facebook/__init__.py line 1292+ from this:

    if params.get('expires'):
        self.session_key_expires = int(params['expires'])

To this:

    if params.get('expires'):
        if params['expires'] == 'None':
            params['expires'] = 0   
        self.session_key_expires = int(params['expires'])

It will work, but it is a hack and maybe it could be done more elegantly, but it works.
Gotta point the pyFacebook devs to this thread, maybe they will have a better solution.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

昨迟人 2024-08-24 02:23:17

在将 pyfacebook 与 facebook-connect 一起使用时,不应使用 pyfacebook 的装饰器 @facebook.require_login() 。该装饰器旨在用于 Facebook 应用程序,因为如果用户未登录,它会将用户重定向到 Facebook 网站,但如果用户未登录,您确实希望将用户重定向到网站上的登录页面。

要检查某人是否使用 djangofb 中间件通过 facebook-connect 和 pyfacebook 登录,请调用 request.fb.check_session(request)。如果 check_session 返回 True,则他们有一个有效的会话。如果它返回 False 那么您需要将用户重定向到您的登录页面,以便他们可以单击您(应该)放置在该页面上的 facebook connect 登录按钮。

You should not use pyfacebook's decorator @facebook.require_login() when using pyfacebook with facebook-connect. The decorator is meant to be used for a facebook application, as it redirects the user to the facebook site if they are not logged in, but you really want to redirect the user to your login page on your site if they are not logged in.

To check if someone is logged in with facebook-connect and pyfacebook with the djangofb middleware, you call request.fb.check_session(request). If check_session returns True then they have a valid session. If it returns False then you need to redirect the user to your login page so they can click the facebook connect login button you (should) have placed on that page.

情感失落者 2024-08-24 02:23:17

如果您将 facebook/__init__.py 第 1292+ 行从以下位置更改

    if params.get('expires'):
        self.session_key_expires = int(params['expires'])

    if params.get('expires'):
        if params['expires'] == 'None':
            params['expires'] = 0   
        self.session_key_expires = int(params['expires'])

:它将起作用,但它是一个 hack,也许它可以做得更优雅,但它确实有效。

If you change facebook/__init__.py line 1292+ from this:

    if params.get('expires'):
        self.session_key_expires = int(params['expires'])

To this:

    if params.get('expires'):
        if params['expires'] == 'None':
            params['expires'] = 0   
        self.session_key_expires = int(params['expires'])

It will work, but it is a hack and maybe it could be done more elegantly, but it works.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文