Getting a graph object

Now that you have Django Facebook up and running you’ll want to make API calls to Facebook. The first step is getting an OpenFacebook object setup.

User object

For users which registered through Django Facebook, you’ll have an access token stored in the database. Note that by default tokens expire quickly (couple of hours), Django Facebook will try to extend these to 60 days.

graph = user.get_offline_graph()

From the request

If you’ve just authenticated via Facebook you can get the graph from the request as such

# persistent (graph stored in session)

# not persistent

Typically you’ll use the decorators in views where you access Facebook.

Access token

For mobile apps you’ll sometimes get an access token directly

from open_facebook import OpenFacebook
graph = OpenFacebook(access_token)