Models¶
- class django_facebook.models.BaseFacebookModel(*args, **kwargs)[source]¶
Abstract class to add to your profile or user model. NOTE: If you don’t use this this abstract class, make sure you copy/paste the fields in.
- extend_access_token()[source]¶
https://developers.facebook.com/roadmap/offline-access-removal/ We can extend the token only once per day Normal short lived tokens last 1-2 hours Long lived tokens (given by extending) last 60 days
The token can be extended multiple times, supposedly on every visit
- get_offline_graph()[source]¶
Returns a open facebook graph client based on the access token stored in the user’s profile
- django_facebook.models.BaseFacebookProfileModel¶
alias of BaseFacebookModel
- class django_facebook.models.BaseModel(*args, **kwargs)[source]¶
Stores the fields common to all incentive models
- class django_facebook.models.CreatedAtAbstractBase(*args, **kwargs)[source]¶
Stores the fields common to all incentive models
- class django_facebook.models.FacebookCustomUser(*args, **kwargs)[source]¶
The django 1.5 approach to adding the facebook related fields
- class django_facebook.models.FacebookLike(*args, **kwargs)[source]¶
Model for storing all of a users fb likes
- class django_facebook.models.FacebookModel(*args, **kwargs)[source]¶
the image field really destroys the subclassability of an abstract model you always need to customize the upload settings and storage settings
thats why we stick it in a separate class
override the BaseFacebookProfile if you want to change the image
- class django_facebook.models.FacebookProfile(*args, **kwargs)[source]¶
Not abstract version of the facebook profile model Use this by setting AUTH_PROFILE_MODULE = ‘django_facebook.FacebookProfile’
- django_facebook.models.FacebookProfileModel¶
alias of FacebookModel
- class django_facebook.models.FacebookUser(*args, **kwargs)[source]¶
Model for storing a users friends
Object for tracking all shares to Facebook Used for statistics and evaluating how things are going
I recommend running this in a task Example usage:
from user.models import OpenGraphShare user = UserObject url = 'http://www.fashiolista.com/' kwargs = dict(list=url) share = OpenGraphShare.objects.create( user = user, action_domain='fashiolista:create', content_object=self, ) share.set_share_dict(kwargs) share.save() result = share.send()
Advanced usage:
share.send() share.update(message='Hello world') share.remove() share.retry()
Using this model has the advantage that it allows us to
- remove open graph shares (since we store the Facebook id)
- retry open graph shares, which is handy in case of
- updated access tokens (retry all shares from this user in the last facebook_settings.FACEBOOK_OG_SHARE_RETRY_DAYS)
- Facebook outages (Facebook often has minor interruptions, retry in 15m, for max facebook_settings.FACEBOOK_OG_SHARE_RETRIES)
Determines if the exceptions is something which requires us to ask for a new token. Examples are:
Error validating access token: Session has expired at unix time 1350669826. The current unix time is 1369657666.
(#200) Requires extended permission: publish_actions (error code 200)
Update the share with the given data