An (Relatively) Easy Way for Installing Social Feed Manager on Mac OSX

On Monday, March 24, 2014 at Code4Lib 2014 Conference in Raleigh, North Carolina, i was fortunate to get the opportunity to learn Social Feed Manager (SFM), directly from the developers, Daniel Chudnov, Daniel Kerchner and also Laura Wruber from George Washington University (thank you for all of you for patienly guide me to get SFM working). SFM is a django application for managing multiple feeds of social media data. It's been a long time i'm searching for this kind of software to grab social media feed from Twitter. I know that Twitter already provide an API to fetch tweets, but i'm too lazy to learn the API :D, so SFM is great solution for me.

This article will try to explain step by step on how to install SFM on Mac OSX. Why Mac OSX? because i use Mac OSX on Macbook Air everyday for my work. Currently at the time this article was written, i'm using Mac OSX version 10.7.5 (Lion) with latest update from Apple. Below are the specs of my Macbook Air:

Ok, lets get it started, before installing SFM on Mac OSX you NEED to have/install these requirements:

  1. A working (and fast if you have) Internet connection
  2. A Twitter account!
  3. Latest Xcode. After finished installing Xcode, open the Xcode.app and accept the Xcode license agreement.
  4. Latest PostgreSQL database server for Mac OSX. I prefer Postgres.app, "The easiest way to get started with PostgreSQL on the Mac" <- that's what they said about it, and i think it is true :)
  5. and after installing Xcode and PostgreSQL, you need to install Homebrew, a package manager similiar to apt on Ubuntu for Mac OSX.

After successfully installing above three softwares, now you must open Terminal application (press Command+Space button and type "Terminal" if you're too lazy to find it :D) and do the "geek typing" works :D. If you

First installing python package manager, "pip" by typing:

$ sudo easy_install pip

Second, you need to install python "virtualenv" package by typing:

$ sudo pip install virtualenv
with virtualenv you can localize all required python library dependacies only on project directory (in this case is SFM).

Now, we start to install the SFM itself by cloning the source code directly from the SFM GitHub repository by typing:

$ cd
$ git clone git://github.com/gwu-libraries/social-feed-manager.git
$ cd social-feed-manager
In this example, we install the SFM on our home directory. You will see that there is social-feed-manager directory on our home directory now.

Currently, we are inside the social-feed-manager directory. We will create a virtual environment directory inside this folder, and we name it ENV by invoking below commands:

$ virtualenv --no-site-packages ENV
$ source ENV/bin/activate
You will see there is something a bit different with our command shell, it is appended with "(ENV)" which means that we are already inside our python sandbox/virtual environment.

So far so good? Hopefully! :D. Don't worry we will see our SFM working in a few hour to go hahaha, just kidding, in a "few steps" to go. Next step is preparing our PostgreSQL database for SFM to store its data, so we will launch our Postgres.app application and click "Open psql" button to open "psql" terminal. On psql console type below commands:

CREATE USER sfmuser with createdb PASSWORD 'sfmuser_secret';
CREATE DATABASE sfmdb WITH OWNER sfmuser;
Remember we create a new database user/role named "sfmuser" with password "sfmuser_secret" and database named "sfmdb". We will use these values on SFM configuration file later.

Now go back to the first Terminal application where we installing SFM. We will install all python library dependancies needed by SFM such as Django, Django Social Auth, Oauth, and etc. using below command:

$ pip install -r requirements.txt
Just wait until all process finished, and if everything is running smooth you'll see like this:

Continue! now type the following commands:

$ cd sfm
$ cp sfm/local_settings.py.template sfm/local_settings.py
$ nano sfm/local_settings.py
Now you'll see that you're opening the local_settings.py file using nano text editor (yes, you can use another text editors to edit the file if you're allergic to nano), and you must edit some value inside it according to your twitter app configuration. To create your Twitter app, login to https://apps.twitter.com using your Twitter account and create new application in https://apps.twitter.com/app/new. Fill the new application form like mine below:

After creating your new Twitter application will get an API Key like this.

On local_settings.py you need to change these lines according to your database settings


DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'sfmdb',
        'USER': 'sfmuser',
        'PASSWORD': 'sfmuser_secret',
        'HOST': 'localhost',
        'PORT': '5432',
    }
}
You MUST also change below lines according to your Twitter app API settings
TWITTER_DEFAULT_USERNAME = 'YOUR TWITTER USERNAME'
TWITTER_CONSUMER_KEY = 'YOUR TWITTER API KEY'
TWITTER_CONSUMER_SECRET = 'YOUR TWITTER API SECRET'
Save the changes by pressing Control+X and then press Y (if you're using nano).

Now you must edit the wsgi.py file by typing these commands:

$ cp sfm/wsgi.py.template sfm/wsgi.py
$ nano sfm/wsgi.py
Remove "#" in front of lines like below and change the ENV line so it will be look like this :
import site
ENV = '/Users/arienugraha/social-feed-manager/ENV'
site.addsitedir(ENV + '/lib/python2.7/site-packages')
Don't forget to save the changes by pressing Control+X and then press Y (if you're using nano).

Next step we will create setup a database to be used by djago by typing this command

$ ./manage.py syncdb
You'll be asked to create superuser for SFM administration page (DON'T USE YOUR TWITTER USERNAME!). In this article i create superuser with username "admin" and password "admin". If everything went smooth you'll something like this:

Next run this:

$ ./manage.py migrate

Hoorrayyyy!!! we almost finished! Next we need to run the Django built in web server (yes, you don't have to use Apache or another web server for development and testing) so we can access SFM administration UI. Run below command

$ ./manage.py runserver
Open your web browser and go to http://localhost:8000/admin to access SFM administration UI. By default Django web server will run on port 8000. If you want Django to run on another port, say it port 9090, just run the command like this :
$ ./manage.py runserver 9090
and go to http://localhost:9090/admin on your web browser! You'll see something like this on your web browser if everything is OK :

Login with username we already create on previous "syncdb" step, in this example the username is "admin" and the password is "admin", and you'll see webpage like this:

Fiuuhhhh!!! now we have our SFM installed and we are ready to grab Twitter feeds we want. The question is HOW DO I GRAB THE FEEDS THAT I WANT? Relax bro, relax :D. Suppose we want to grab tweets from Twitter user named @slims_official, what we must do is adding her/his Twitter screen name on http://localhost:8000/admin/ui/twitteruser/add/ and fill it on Name form field like this:

then click "Save" button at the bottom of the screen. Now on Terminal, run this command to grab about 3200 latest tweets from this user:
$ ./manage.py user_timeline
and you'll see something like this on your Terminal screen:
You see that SFM grab 200 tweets each time from the latest to the older tweets.

That's it hopefully you will find this article useful. Next i will try to write an article on how to use/utilize feeds from SFM with PHP. (Please don't ask me about Python and Django, i can only write standard "Hello World" using Python :D)

Komentar

Gennie mengatakan…
It's really a helpful article about social media,.
Best social media app for iOS Android
steward mengatakan…
it's a very informative article,
pushdot
steward mengatakan…
Keep sharing more informative post like that,
ios app development company bangalore
steward mengatakan…
It's really an amazing and nice blog,
Thanks for sharing with us,.
social network for original ideas
Unknown mengatakan…
Nice post. I learn something more challenging on different blogs everyday. It will always be stimulating to read content from other writers and practice a little something from their store. I’d prefer to use some with the content on my blog whether you don’t mind. Natually I’ll give you a link on your web blog. Thanks for sharing.
ios app development company
steward mengatakan…
It's a best post about android app development,
android nougat news
latesttechnologyblogs mengatakan…

Thanks for sharing amazing information about python .Gain the knowledge and hands-on experience in python online training
Tech Nerd mengatakan…
Thanks for sharing amazing information about python.

remote monitoring telehealth software
mobile app development company
Anubhuti Mittal mengatakan…
Are you searching for app development companies in Saudi Arabia? This list of Top Mobile App Development Companies in Riyadh, Saudi Arabia will make you easy to find a reliable app maker. Below the list of the best mobile app development companies in Riyadh, is listed as per company ranking in the GoodFirms. Which will help you hire dedicated app development companies in Saudi Arabia?
Anubhuti Mittal mengatakan…
TechGropse is the leading mobile app development company in Dubai which provides you with the best services in developing android apps and iPhone apps. We have a team of trained professionals who concentrate strongly on designing and implementing mobility solutions. Our developers have developed a range of feature-rich applications for different platforms including Android, iOS, and Windows.

Postingan populer dari blog ini

Template Aplikasi Web CRUD Sederhana dengan CodeIgniter

Instalasi library YAZ di PHP