Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/intelligenia/django-last-social-activity
A simple application for Django to fetch the last posts of your social network profiles in your site.
https://github.com/intelligenia/django-last-social-activity
django facebook instagram pinterest profile rss social-network twitter
Last synced: 23 days ago
JSON representation
A simple application for Django to fetch the last posts of your social network profiles in your site.
- Host: GitHub
- URL: https://github.com/intelligenia/django-last-social-activity
- Owner: intelligenia
- License: mit
- Created: 2017-02-02T14:55:35.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-04-09T20:21:16.000Z (over 4 years ago)
- Last Synced: 2024-10-03T09:31:17.588Z (about 1 month ago)
- Topics: django, facebook, instagram, pinterest, profile, rss, social-network, twitter
- Language: Python
- Size: 33.2 KB
- Stars: 1
- Watchers: 7
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE
Awesome Lists containing this project
README
# django-last-social-activity
A simple application for [Django](https://www.djangoproject.com/) to fetch the last posts of your social network profiles in your site.
# Introduction
This 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 is [https://github.com/intelligenia/django-last-social-activity](https://github.com/intelligenia/django-last-social-activity).
The main aim of this software is having [Django template tags](https://docs.djangoproject.com/en/1.10/howto/custom-template-tags/) ready to load your last posts in templates:
```html
{# Load django-last-social-activity template tags #}
{% load last_social_activity %}```
The idea is personalize the default templates in your **templates** folder as you need.
# Installation
[This package is in pypi](https://pypi.python.org/pypi/django-last-social-activity) so you can install it easily using pip command:
```sh
pip install django-last-social-activity
```or install it from [this GitHub repository](https://github.com/intelligenia/django-last-social-activity) if you want last features of the master branch:
```sh
# Master will allways be stable
pip install https://github.com//intelligenia/django-last-social-activity/archive/master.zip```
# Dependencies
This package depends on some other Python packages:
- beautifulsoup4
- python-dateutil
- python-twitter
- requestsThey are included in the requirements of this package so you won't have to install them by hand.
# Configuration
## Django settings.py
The first step is include the application **last_social_activity** to your INSTALLED_APPS tuple:```python
INSTALLED_APPS = (
#...
"last_social_activity"
#...
)```
The second step is configuring what social networks you want to include in your site.
Put this dictionary in your **settings.py** file filling the.
```python
LAST_SOCIAL_ACTIVITY_CREDENTIALS = {
"twitter": {
"profile_url": "",
"username": "",
"consumer_key": "",
"consumer_secret": "",
"access_token_key": "",
"access_token_secret": ""
},
"instagram": {
"profile": "",
"access_token" :""
},
"pinterest": {
"profile": "",
"access_token" :""
},
"facebook": {
"profile": "",
"access_token" :""
},
"fivehundred":{
"profile": "<500px username>",
"access_token": "<500px consumer key>"
}
"flickr":{
"access_token": "",
"user_id": "",
"album_id": ""
}
"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:
```python
# Cache stores information for 1 hour
LAST_SOCIAL_ACTIVITY_CACHE_DURATION_IN_HOURS = 1
LAST_SOCIAL_ACTIVITY_CACHE_DURATION_IN_MINUTES = None
LAST_SOCIAL_ACTIVITY_CACHE_DURATION_IN_SECONDS = None
```By 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.
## Migrations
Don't forget to execute migrations to create cache table for this application.```sh
python manage.py migrate
```# Use
## Template tags
Load this template tag in your templates:
```html
{% load last_social_activity %}
```For example:
```html
{# 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 %}```
## Customization
Customize each one of the templates creating a directory **last_social_activity** with one child with the name
**social_networks**. That directory will contain a template for each social network (and your RSS channel if is configured):- facebook.html
- instagram.html
- pinterest.html
- rss.html
- twitter.html
- fivehundred.html
- flickr.htmlYou have a list of post objects called **posts** with the following attributes:
- id: id of this post
- name: 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 the [default template](last_social_activity/templates/last_social_activity/social_networks/facebook.html) for an example.
Data available comes from the member **data** of the following URL: [https://api.instagram.com/v1/users/self/media/recent/?access_token=XXXX](https://www.instagram.com/developer/endpoints/users/#get_users_media_recent_self)
Look to the [default template](last_social_activity/templates/last_social_activity/social_networks/instagram.html).
Available fields are the ones returned by [https://api.pinterest.com/v1/me/pins/?access_token=XXXX](https://developers.pinterest.com/docs/api/pins/).
Look to the [default template](last_social_activity/templates/last_social_activity/social_networks/pinterest.html).
### 500px
Available fields are the ones returned by [https://api.500px.com/v1/photos?consumer_key=XXXX](https://github.com/500px/api-documentation).
Look to the [default template](last_social_activity/templates/last_social_activity/social_networks/fivehundred.html).
### Flickr
Available fields are the ones returned by [https://api.flickr.com/services/rest/](https://www.flickr.com/services/api/).
Look to the [default template](last_social_activity/templates/last_social_activity/social_networks/flickr.html).
### RSS
All RSS data is available as context in the template in the **rss_items** list.
You can access to all the attributes of each of your RSS items: name, description, pubdate, etc.
Look to the [default template](last_social_activity/templates/last_social_activity/social_networks/rss.html).
Available context is a dict with the following structure:
```python
{
"tweets": [
{
"id": "",
"text": "",
"created_at": ""
},
# ...
],
"profile_url": "",
"username": ""
}```
Look to the [default template](last_social_activity/templates/last_social_activity/social_networks/twitter.html).
# Authors
- Francisco Morales Gea ([email protected]) (development)
- Diego J. Romero López ([email protected]) (corresponding author, software architecture, caching and fault-tolerance)Remove REMOVETHIS before emailing to one of the authors.