django-social-feeds-parser is a django application to store and display feed coming from social medias such as:
This library is a fork of Tomasz Roszko's django-spokeaboutus
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
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:
SOCIALFEEDSPARSER_FACEBOOK_CLIENT_ID = "your app client_id"
SOCIALFEEDSPARSER_FACEBOOK_CLIENT_SECRET = "your app client secret"
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"
SOCIALFEEDSPARSER_INSTAGRAM_ACCESS_TOKEN = "your app access token"
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'
)
urlpatterns = patterns('',
...
url(r'^social-feeds-parser/', include('socialfeedsparser.urls')),
...
)
python manage.py syncdb
python manage.py migrate
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).
Run this command (you can of course add it to a cronjob or a scheduled broker):
python manage.py collect_social_feeds
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' %}
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)
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."
- use celery to process news
- write tests
- support python3.4 for twitter and instagram