1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
This is a sample Django application for PyFacebook.
To use this application, copy the entire folder to an existing
Django application. Then you need to edit the following settings:
* In settings.py, make sure that TEMPLATE_LOADERS contains
'django.template.loaders.app_directories.load_template_source'. This
is so that templates can be loaded from this template directory.
* In settings.py, define FACEBOOK_API_KEY and FACEBOOK_SECRET_KEY to your
own values.
* In settings.py, add the following line to the variable MIDDLEWARE_CLASSES:
'facebook.djangofb.FacebookMiddleware'. This will attach a facebook object
to every incoming request.
* However if you don't wan't to attach a facebook object to every incoming
request you can use the middleware as a decorator.
from django.utils.decorators import decorator_from_middleware
from facebook.djangofb import FacebookMiddleware
@decorator_from_middleware(FacebookMiddleware)
@facebook.require_login()
def canvas(request):
...
* In urls.py, have something in your urlpatterns like:
(r'^facebook/', include('YOUR_PROJECT_NAME.pyfacebook_sample.urls')),
This will tell the sample application to live under /facebook/.
* On the Facebook applications page, make sure that you set your callback
to the appropriate URL. In this example, it would be
'http://YOUR_IP/facebook/canvas/', and DON'T FORGET THE TRAILING SLASH :-)
* Change any occurrences of pyfacebook to your own application name.
That should be about it...
|