15

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?

byamabe
  • 1,421
  • 1
  • 12
  • 19

3 Answers3

8

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
  • 7,843
  • 1
  • 27
  • 25
6

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
  • 1,421
  • 1
  • 12
  • 19
  • 3
    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 Jun 16 '09 at 12:50
  • 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 Jan 11 '10 at 02:41
  • 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 Jan 11 '10 at 03:59
  • Because I was looking, personally, I'd like to note that this works in vanilla GAE app too. Just follow precise instructions. – noio Dec 27 '11 at 17:18
0

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
  • 854,459
  • 170
  • 1,222
  • 1,395
  • The link in that post seems to be broken? – bchang Jun 11 '09 at 22:33
  • Yep, so I edited my answer to give a better pointer (to the same modified PyFacebook) -- thanks! – Alex Martelli Jun 12 '09 at 01:39
  • 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 Jun 12 '09 at 02:42