Package: django-last-social-activity
django-last-social-activityA simple application forDjangoto
fetch the last posts of your social network profiles in your site.IntroductionThis package allows you to fetch your last status from your favorite
social networks without having to reimplement any functionality or
integrating them on the browser side.The development repository ishttps://github.com/intelligenia/django-last-social-activity.The main aim of this software is havingDjango template
tagsready to load your last posts in templates:{# Load django-last-social-activity template tags #}
{% load last_social_activity %}<divclass="my-social-networks">{# Get the last 10 items of your RSS 'myblog' as defined in settings.py #}
  {% last_rss_items 'myblog' 10 %}

  {# Get the last 3 posts of your Facebook wall #}
  {% last_facebook_posts 3 %}

  {# Get the last 8 tweets #}
  {% last_tweeets 8 %}

  {# Get the last 12 images of Instagram #}
  {% last_instagram_media 12 %}

  {# Get the last 15 pins of Pinterest #}
  {% last_pinterest_pins 15 %}

  {# Get the last 25 photos of 500px #}
  {% last_fivehundred_media 25 %}

  {# Get the last 5 photos of flickr #}
  {% last_flickr_media 5 %}</div>The idea is personalize the default templates in yourtemplatesfolder as you need.InstallationThis package is in
pypiso
you can install it easily using pip command:pipinstalldjango-last-social-activityor install it fromthis GitHub
repositoryif you want last features of the master branch:# Master will allways be stablepipinstallhttps://github.com//intelligenia/django-last-social-activity/archive/master.zipDependenciesThis package depends on some other Python packages:beautifulsoup4python-dateutilpython-twitterrequestsThey are included in the requirements of this package so you won’t have
to install them by hand.ConfigurationDjango settings.pyThe first step is include the applicationlast_social_activityto
your INSTALLED_APPS tuple:INSTALLED_APPS=(#..."last_social_activity"#...)The second step is configuring what social networks you want to include
in your site.Put this dictionary in yoursettings.pyfile filling the.LAST_SOCIAL_ACTIVITY_CREDENTIALS={"twitter":{"profile_url":"<your twitter profile>","username":"<your twitter username>","consumer_key":"<consumer key>","consumer_secret":"<consumer secret>","access_token_key":"<access token key>","access_token_secret":"<access token secret>"},"instagram":{"profile":"<instagram username>","access_token":"<instagram access token>"},"pinterest":{"profile":"<pinterest username>","access_token":"<pinterest access token>"},"facebook":{"profile":"<facebook username>","access_token":"<facebook access token>"},"fivehundred":{"profile":"<500px username>","access_token":"<500px consumer key>"}"flickr":{"access_token":"<flickr access token>","user_id":"<flickr user id>","album_id":"<album id>"}"rss":{"<RSS source id>"{"url":"<main URL of the site>","rss_url":"<RSS URL>",}}}If you don’t want to fetch some social network (or don’t have an
account), you can leave empty the dictionary for that social network.Thus, you have to include the cache configuration:# Cache stores information for 1 hourLAST_SOCIAL_ACTIVITY_CACHE_DURATION_IN_HOURS=1LAST_SOCIAL_ACTIVITY_CACHE_DURATION_IN_MINUTES=NoneLAST_SOCIAL_ACTIVITY_CACHE_DURATION_IN_SECONDS=NoneBy default, it caches the last posts/items in your profile in each
social network for 1 hour if you want to change that, set None the
fields you don’t want and set a number for the field you want.Note the amount of duration is not additive so you only can define max
lifetime for full hours, minutes and seconds.MigrationsDon’t forget to execute migrations to create cache table for this
application.pythonmanage.pymigrateUseTemplate tagsLoad this template tag in your templates:{% load last_social_activity %}For example:{# Get the last 10 items of your RSS 'mysite' channel as defined in settings.py #}
{% last_rss_items 'mysite' 10 %}

{# Get the last 3 posts of your Facebook wall #}
{% last_facebook_posts 3 %}

{# Get the last 8 tweets #}
{% last_tweeets 8 %}

{# Get the last 12 images of Instagram #}
{% last_instagram_media 12 %}

{# Get the last 15 pins of Pinterest #}
{% last_pinterest_pins 15 %}

{# Get the last 25 photos of 500px #}
{% last_fivehundred_media 25 %}

{# Get the last 5 images of Flickr #}
{% last_flickr_media 5 %}CustomizationCustomize each one of the templates creating a directorylast_social_activitywith one child with the namesocial_networks. That directory will contain a template for each
social network (and your RSS channel if is configured):facebook.htmlinstagram.htmlpinterest.htmlrss.htmltwitter.htmlfivehundred.htmlflickr.htmlFacebookYou have a list of post objects calledpostswith the following
attributes:id: id of this postname: title of the post.created_time: creation datetime of the post.type: type of the post.message: content of the post.link: link to this facebook post.permalink_url: link to this facebook post.Take a look to thedefault
templatefor an example.InstagramData available comes from the memberdataof the following URL:https://api.instagram.com/v1/users/self/media/recent/?access_token=XXXXLook to thedefault
template.PinterestAvailable fields are the ones returned byhttps://api.pinterest.com/v1/me/pins/?access_token=XXXX.Look to thedefault
template.500pxAvailable fields are the ones returned byhttps://api.500px.com/v1/photos?consumer_key=XXXX.Look to thedefault
template.FlickrAvailable fields are the ones returned byhttps://api.flickr.com/services/rest/.Look to thedefault
template.RSSAll RSS data is available as context in the template in therss_itemslist.You can access to all the attributes of each of your RSS items: name,
description, pubdate, etc.Look to thedefault
template.TwitterAvailable context is a dict with the following structure:{"tweets":[{"id":"<id of this tweet>","text":"<content of the tweet>","created_at":"<creation datetime of this tweet>"},# ...],"profile_url":"<twitter_profile_url>","username":"<twitter_username>"}Look to thedefault
template.AuthorsFrancisco Morales Gea
(REMOVETHISfrancisco.REMOVETHISmorales@intelligenia.com)
(development)Diego J. Romero López (diegoREMOVETHIS@intelligenia.com)
(corresponding author, software architecture, caching and
fault-tolerance)Remove REMOVETHIS before emailing to one of the authors.