assembl.models.facebook_integration module

Utilities for extracting posts and comments from Facebook, using the facebook API.

class assembl.models.facebook_integration.FacebookAPI(user_token=None)[source]

Bases: object

Proxy object to the unofficial facebook sdk

class assembl.models.facebook_integration.FacebookAccessToken(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base

container_url()[source]

What is the URL where we expect to find this resource

is_expired()[source]

An access token is considered never-expiring when the expiration is None.

is_owner(user_id)[source]

The user owns this ressource, and has more permissions.

classmethod restrict_to_owners_condition(query, user_id, alias=None, alias_maker=None)[source]

filter query according to object owners

class assembl.models.facebook_integration.FacebookGenericSource(**kwargs)[source]

Bases: assembl.models.generic.PostSource

A generic source

fetch_content(lower_bound=None, upper_bound=None)[source]

The entry point of creating posts

Parameters
  • lower_bound (DateTime) – Read posts up to this back in time

  • uppder_bound (DateTime) – Read future posts up to this time

reprocess()[source]

Update all posts/users from this source without hitting the network

user_access_token()[source]

Firstly, checks to ensure that a creator exists, otherwise, the db query might return awkward results. Then checks for user token existence and not-expired

class assembl.models.facebook_integration.FacebookGroupSource(**kwargs)[source]

Bases: assembl.models.facebook_integration.FacebookGenericSource

fetch_content(lower_bound=None, upper_bound=None, reimport=False)[source]

The entry point of creating posts

Parameters
  • lower_bound (DateTime) – Read posts up to this back in time

  • uppder_bound (DateTime) – Read future posts up to this time

class assembl.models.facebook_integration.FacebookGroupSourceFromUser(**kwargs)[source]

Bases: assembl.models.facebook_integration.FacebookGenericSource

fetch_content(lower_bound=None, upper_bound=None, reimport=False)[source]

The entry point of creating posts

Parameters
  • lower_bound (DateTime) – Read posts up to this back in time

  • uppder_bound (DateTime) – Read future posts up to this time

class assembl.models.facebook_integration.FacebookPageFeedSource(**kwargs)[source]

Bases: assembl.models.facebook_integration.FacebookGenericSource

fetch_content(lower_bound=None, upper_bound=None, reimport=False)[source]

The entry point of creating posts

Parameters
  • lower_bound (DateTime) – Read posts up to this back in time

  • uppder_bound (DateTime) – Read future posts up to this time

class assembl.models.facebook_integration.FacebookPagePostsSource(**kwargs)[source]

Bases: assembl.models.facebook_integration.FacebookGenericSource

fetch_content(lower_bound=None, upper_bound=None, reimport=False)[source]

The entry point of creating posts

Parameters
  • lower_bound (DateTime) – Read posts up to this back in time

  • uppder_bound (DateTime) – Read future posts up to this time

class assembl.models.facebook_integration.FacebookParser(api)[source]

Bases: object

The main object to interact with to get source endpoints The API proxy is injected no construction to have flexibility as to which API sdk to use

get_comment_attachments(comment_id)[source]

Will return an object dict

get_post_attachments(post_id)[source]

Currently (10/15/2015) there is only 1 attachment allowed per facebook post. Therefore, pass the first available one

parse_attachment(attachment)[source]

Returns attachment in the format:

{

‘url’: x, ‘title’: y, ‘description’: z

}

class assembl.models.facebook_integration.FacebookPost(*args, **kwargs)[source]

Bases: assembl.models.post.ImportedPost

A facebook post, from any resource on the Open Graph API

body_mime_type

The mime type of the body of the imported content. See Content::get_body_mime_type() for allowed values.

classmethod create(source, post, user)[source]

Create an instance. Not used.

message_id

The email-compatible message-id for the post.

source_post_id

The source-specific unique id of the imported post. A listener keeps the message_id in the post class in sync

class assembl.models.facebook_integration.FacebookSinglePostSource(**kwargs)[source]

Bases: assembl.models.facebook_integration.FacebookGenericSource

fetch_content(lower_bound=None, upper_bound=None, reimport=False)[source]

The entry point of creating posts

Parameters
  • lower_bound (DateTime) – Read posts up to this back in time

  • uppder_bound (DateTime) – Read future posts up to this time