How FTOTW works?

How it works?

Shorter Version

It fetches retweets from Twitter and adds them to WordPress DB, after assigning a score to each of them. The retrieved tweets are used to create a weekly post about the most interesting tweets that were retweeted. The Plugin also creates a leaderboard which displays the twitter users with the highest score.

Longer Version

The Plugin has the following different components

Fetching FTOTW Retweets

This is the major pain point in the entire workflow because of the ever changing Twitter developer guidelines. There were 3 other implementations, in addition to the one described below, which had to be developed and then abandoned because of the changes in Twitter Developer guidelines and API.

Whenever, Sukumar posts a FTOTW styled retweet, it is fetched and processed by the plugin.

Earlier this plugin had a WordPress based cron job, which was running once every day and was fetching Sukumar’s twitter stream and then was filtering out the FTOTW styled retweets. But with recent changes in Twitter API, this as no longer possible.

The current implementation uses IFTTT service to fetch FTOTW styled retweets from Sukumar’s twitter stream.

IFTTT

IFTTT is a service which allows you to easily create actions based on triggers. There is an extension to IFTTT that allows you to trigger custom scripts based on some actions.

This Plugin uses twitter as a trigger and a custom PHP script as an action to retrieve tweets from Sukumars twitter stream. After retrieving the tweets, FTOTW styled retweets are identified and they are passed to the next module.

Calculate Wings (score)

Each tweet is assigned a Wing (score) in the scale of 1-4. The actual logic which is used to calculate Wings is explained in this blog post.

Once wings are calculated the tweet, tweet author and the wing are inserted into WordPress DB.

Create FTOTW posts

Once a week (usually Sunday evening), a WordPress based cron job kicks in and retrieves all the tweets, that were posted in that week and creates a new FTOTW based post.

It also keeps track of the last tweet that got into the post, so that next week, it can retrieve tweets which were posted after it.

Leaderboard Page

The leaderboard page is created by retrieve the list of tweet authors in descending order of the total number of wings they have. It is just a WordPress page but with a custom page template, which retrieves the content from DB to create the nice leaderboard table.

Open source

The plugin is released under GPL license and can be downloaded from github. Kindly note that this is heavily customized for http://www.sastwingees.org/ and may not be plug and play for your usecase.