Track Friends and Topics on Social Networks Using Intel Edison

by Douglas N in Circuits > Wireless

1398 Views, 11 Favorites, 0 Comments

Track Friends and Topics on Social Networks Using Intel Edison

stalkedison.jpg

Build your own social media assistant with an Intel Edison and a few python scripts! This a fairly simple project that will allow you to see your own facebook/twitter news feed filtered as you like it.

Explore the code and the libraries used and you will easily be able to do any project using data from social networks.

Load Debian (Ubilinux) to Your Edison

ubilinux_logo_big.png

This step can be skipped if you already have a working OS that runs python scripts on your Edison board. At first we tried using the Yocto distribution but it was missing a basic python package, so we switched to Ubilinux.

Here you can find an easy step-by-step guide on how to load Ubilinux onto your Edison.

Install and Update Pip

install pip.PNG

The python script that analyses your timeline on facebook/twitter will require a few libraries, so you need to install them before trying to run the main script.

In order to do that, we'll use pip. Pip is a tool that allows you to easily download and install any python library.

Connect to your Edison through the serial port and enter apt-get install python-pip (using sudo or logged in as root).

Reboot your edison by entering reboot. Log back in and type pip install --upgrade pip to update your pip. Reboot again.

Install Required Packages Using Pip

install mechanize.PNG

Now that you have pip installed and updated, go ahead and enter sudo pip install mechanize.

This package enables the script to create a virtual web browser, so that it can log in to your facebook account and be allowed to request information from facebook.

If you want to be sure, you can type in sudo ldconfig -p | grep mechanize. If there is no output after your ldconfig command, then mechanize was successfully installed.

Do the same for the packages requests and tweepy.

Install Apache Web Server

Screenshot from 2015-06-30 13:17:13.png

Apache Web Server will allow us to access the HTML output files generated by Stalkline from another computer on the same network of Intel Edison board. Setup is pretty simple: just type sudo apt-get install apache2.

After setup, test the Apache installation typing Intel Edison's IP address in a web browser connected to the same network (get your IP address typing the command sudo ifconfig in ubilinux). You will see the Apache's default web page (It Works!)

Clone Our Git Repository

Screenshot from 2015-06-30 14:17:18.png

Choose a directory to install Stalkline files (/home/your_username/ or /home/root/ will work fine) and type git clone https://github.com/renanlino/stalkline-en.git. Git will copy the source files from my GitHub repository to the stalkline folder inside your working directory.

Also, there is a brazilian portuguese version of Stalkline. Clone with command git clone https://github.com/renanlino/stalkline-pt.git

Initial Setup

Screenshot from 2015-06-30 13:46:40.png

Before you start tracking, you need to setup your social media account information and select desired topics and users to track.
Change working directory to stalkline folder, then run python config.py. Stalkline configuration script will guide you through the setup proccess.

The script needs email and password of your Facebook/Twitter account, but calm down! This information will not leave your Edison in any moment and will not be stored.

Using Stalkline with Facebook requires authorization to read your News Feed (Facebook home). Twitter requires Read Only authorization.

Attention!!! To use Stalkline with Facebook you need access to Stalkline app in Facebook, that still is in development. Send an email to us (renan.lino at gmail.com or douglasnavarro94 at gmail.com) with a link to your Facebook profile and we will provide access in Tester Mode.

Run and Track!

IMG_0480.PNG
IMG_0479.PNG

After initial setup, just run sudo python -W ignore runStalkline.py. Stalkline will get your Facebook/Twitter news feed, search selected topics and users and generate a simple HTML file, stored in folder /var/www that is visible from any computer in the same network.

After first check, type Edison's IP address in a web browser followed by /facebook.html or /twitter.html (EDISON_IP/facebook.html or EDISON_IP/twitter.html) to visualize output. Just refresh the pages to track updates.

Some notes:

1) Twitter API will block requests from our app in your profile after a number of requests, and there's nothing to do about it. Just wait :(

2) To reset the Stalkline (remove old posts), just remove files from output folder. Remove HTML files from /var/www will have no effect on the script.

3) Stalkline for Facebook uses Facebook's Graph API to get News Feed. Graph's News Feed is not exactly equal to your Facebook Homepage. Some posts in your Facebook Homepage may not be tracked by Stalkline due this behavior.

Feel free to tweak the code and to use it to build something bigger or different.