views:

2152

answers:

3

I'm experimenting with app-engine-patch (Django for GAE) on Google App Engine. And I would like to write a Facebook application. Is it possible to use PyFacebook and its middleware? Or is there some other solution?

A: 

According to this post, you need a slightly modified PyFacebook that you can download from a URL given in said post (I haven't tried it myself, though).

Edit: that link is wrong -- better link and more discussion on this thread.

Alex Martelli
The link in that post seems to be broken?
bchang
Yep, so I edited my answer to give a better pointer (to the same modified PyFacebook) -- thanks!
Alex Martelli
I saw that post before asking my question. I downloaded the file and it looks like a self-contained Python interface to Facebook without any relationship to the PyFacebook project (please correct me if I'm wrong). In any case, it didn't seem like the PyFacebook middleware was supported. I found a post (http://groups.google.com/group/app-engine-patch/browse_thread/thread/cca0bb8d661c7b83/24ac7e53baae523b?show_docid=24ac7e53baae523b) where someone is trying something similar. I will try it and post my findings.
byamabe
+2  A: 

I run a system on for social networks and facebook on GAE with back-end in Python, front end in Javascript and Flash. I use mostly client side js libraries to pass data back to the server side datastore. This library for facebook to be exact: http://code.google.com/p/facebookjsapi/

There is a reason for this. Most of what we are doing will be running on its own site, in iframes in different social networks and in widgets etc. But for the most part this has worked very well. It is good because we can swap out our backend at any time or even run it on multiple platforms as it is also using a python rest GAE library but any backend would do with this setup.

Ryan Christensen
+2  A: 

Adding the Facebook directory from the PyFacebook install directory to the app-engine-patch application allows you to add 'facebook.djangofb.FacebookMiddleware', to the MIDDLEWARE_CLASSES in settings.py. Then your view can use 'import facebook.djangofb as facebook' and '@facebook.require_login().'

I haven't gone end to end, but when I tried to display the view preceded by '@facebook.require_login()', I was redirected to the Facebook login.

byamabe
This worked from end to end. With this configuration, I was able to build a photo voting Facebook application with Google App Engine as the backend.
byamabe
I've tried this and it doesn't seem to work for me. I can't use "import facebook.djangofb as facebook," that fails for some reason. Any idea why? Also, the "require_login" bit doesn't work as planned either. Maybe I put the PyFacebook stuff in the wrong directory? Not sure. Can you help?
Bialecki
Did you put the 'facebook' directory at the top level of the project (same level as your 'myapp' in the example project)? Also it should be the 'facebook' directory, not the entire PyFacebook directory. Also, try @facebook.require_add(), but neither will work until the import works.
byamabe