Skip to content

django application to import, store and display posts from feeds coming from social medias (facebook, twitter, instagram)

Notifications You must be signed in to change notification settings

marrog/django-social-feeds-parser

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django-social-feeds-parser

django-social-feeds-parser is a django application to store and display feed coming from social medias such as:

  • facebook
  • twitter
  • instagram

This library is a fork of Tomasz Roszko's django-spokeaboutus

Install

From Github

pip install -e git+https://github.com/revsquare/django-social-feeds-parser.git#egg=django_socialfeeds-parser

Install python-linkedin if needed:

pip install -e git+https://github.com/ozgur/python-linkedin.git@master#egg=python-linkedin

Setup

settings.py

INSTALED_APPS = (
    ...
    'socialfeedsparser',
    ...
)

Configure the social media source you want to trigger. You can of course add you own custom channel source.

SOCIALFEEDSPARSER_SOURCE = (
    'socialfeedsparser.contrib.twitter',
    'socialfeedsparser.contrib.facebook',
    'socialfeedsparser.contrib.instagram',
    'socialfeedsparser.contrib.linkedin',
    'your.socialfeedsparser.source',
)

For each service you add, you will need to configure their API accesses:

Facebook

SOCIALFEEDSPARSER_FACEBOOK_CLIENT_ID = "your app client_id"
SOCIALFEEDSPARSER_FACEBOOK_CLIENT_SECRET = "your app client secret"

Twitter

SOCIALFEEDSPARSER_TWITTER_CONSUMER_KEY = "your app consumer key"
SOCIALFEEDSPARSER_TWITTER_CONSUMER_SECRET = "your app consumer secret key"
SOCIALFEEDSPARSER_TWITTER_ACCESS_TOKEN = "your app access token"
SOCIALFEEDSPARSER_TWITTER_ACCESS_TOKEN_SECRET = "your app access token secret"

Instagram

SOCIALFEEDSPARSER_INSTAGRAM_ACCESS_TOKEN = "your app access token"

LinkedIn

SOCIALFEEDSPARSER_LINKEDIN_API_KEY = "your application api key"
SOCIALFEEDSPARSER_LINKEDIN_API_SECRET = "your application api secret"
SOCIALFEEDSPARSER_LINKEDIN_RETURN_URL = 'http://your.domain.com/social-feeds-parser/linkedin-save-token/'
SOCIALFEEDSPARSER_LINKEDIN_PERMISSIONS = (
    'rw_company_admin',
    'r_basicprofile',
    # 'r_fullprofile',
    'r_emailaddress',
    # 'r_network',
    # 'r_contactinfo',
    'w_share',
    # 'rw_groups',
    # 'w_messages'
)

urls.py

urlpatterns = patterns('',
    ...
    url(r'^social-feeds-parser/', include('socialfeedsparser.urls')),
    ...
)

database

python manage.py syncdb
python manage.py migrate

Configure sources

Each query you setup for a social media is called a "channel". They are configurable from the admin. You can wether parse a user or page feed. Or even use a search query (this functionnality won't work for facebook as the ability to search for posts has been remove from its API).

Collecting messages

Run this command (you can of course add it to a cronjob or a scheduled broker):

python manage.py collect_social_feeds

Templatetags

A simple template tag is provided to display your content in a widget. You can overwrite it by adding your own 'socialfeedsparser/socialfeed_widget.html' file or by setting up a file path in the SOCIALFEEDSPARSER_TAG_TEMPLATE of your settings. You can alternatively pass the template path as an argument in the template tag in case you have several or if they differ depending on the source.

You can also pass the number of items to display in the template tag.

The first argument to pass is the channel instance you want to display.

{% load socialfeedsparser_tags %}
...
{% socialfeed_display channel 5 'widgets/twitter.html' %}

Other

channel.get_posts

You can trigger the published posts by order and descending publication date for a channel instance by using the 'get_posts' method. By default it will return 10 posts. You can change this number by passing it as an argument. For exemple, if you want 5 posts:

channel.get_posts(5)

post.linkified_content

You can use this method to make all urls, hashtags or arobased user names in a message clickable as links:

{{ post.content }}

"This #hashtag is not linkified."

{{ post.linkified_content }}

"This <a href="https://twitter.com/search?q=%s&src=hash" target="_blank">##hashtag</a> is linkified for twitter."

TODO

  • use celery to process news
  • write tests
  • support python3.4 for twitter and instagram

About

django application to import, store and display posts from feeds coming from social medias (facebook, twitter, instagram)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.6%
  • HTML 0.4%