views:

405

answers:

2

I'm trying to add the facebook connect feature to my site, I decided to use django socialregistration.All are setup including pyfacebook, here is my source code.

settings.py

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'facebook.djangofb.FacebookMiddleware',
    'socialregistration.middleware.FacebookMiddleware',
)

urls.py

(r'^callback/$', 'fbproject.fbapp.views.callback'),

views.py

def callback(request):
    return render_to_response('canvas.fbml')

Template

<html>

<body>
{% load facebook_tags %}
{% facebook_button %}
{% facebook_js %}
</body>

</html>

but when I point to the URL, I'm getting this error

Traceback (most recent call last):

  File "C:\Python26\lib\site-packages\django\core\servers\basehttp.py", line 279, in run
    self.result = application(self.environ, self.start_response)

  File "C:\Python26\lib\site-packages\django\core\servers\basehttp.py", line 651, in __call__
    return self.application(environ, start_response)

  File "C:\Python26\lib\site-packages\django\core\handlers\wsgi.py", line 241, in __call__
    response = self.get_response(request)

  File "C:\Python26\lib\site-packages\django\core\handlers\base.py", line 73, in get_response
    response = middleware_method(request)

  File "build\bdist.win32\egg\socialregistration\middleware.py", line 13, in process_request
    request.facebook.check_session(request)

  File "C:\Python26\lib\site-packages\facebook\__init__.py", line 1293, in check_session
    self.session_key_expires = int(params['expires'])

ValueError: invalid literal for int() with base 10: 'None'

Django 1.1.1 *Python 2.6.2*

A: 

Well, it's definitely being caused because either the POST or GET variables have a bad value for expires. Check the form that you're using and the URL's query string to check this.

If you look at the code for facebook/__init__.py you'll see it only tries to set a value for self.session_key_expires if params (which comes from either request.POST or request.GET) already has a value for expires.

Actually, might want to double check the code just to be sure. You should see lines like this in facebook/__init__.py:

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

If not, maybe you have a bad version?

update Now that I think of it, the error message explicitly said that the value was none. Which probably means that they're not including the check if param.get('expires') because I believe that would return None and then resolve to False.

Unless you have the very latest copy of pyfacebook, try downloading it again.

Jordan Reiter
I'm using the latest version..
MMRUser
Glad I was helpful. Just out of curiosity, what was the cause of the problem?
Jordan Reiter
A: 

This is a bug in pyfacebook. See http://github.com/sciyoshi/pyfacebook/issues#issue/26

Björn Lindqvist