4 · 03

How to know all of your unfollowers on Twitter

Here is my easy way to know who unfollows me on Twitter. Or more precisely, how to monitor the changes on your followers list.

First of all, create a simple script named "twitter_changes.sh":

#!/bin/sh

SCREEN_NAME="sam_alba"

( cd $(dirname $(readlink -f $0))
mv latest.log previous.log
curl -s -X GET "http://api.twitter.com/1/statuses/followers.xml?screen_name=${SCREEN_NAME}" | grep -E '^  <(screen_name|name)>' > latest.log
data=$(diff previous.log latest.log)
if [ ! -z "$data" ] ; then
echo "$data" | mail -s "[twitter] changes" -a "From: twitter@shad.cc" $EMAIL
fi
)
Then, execute the script daily with a crontab:
# cd /etc/cron.daily ; ln -s /path/of/your/script twitter_changes

That's it, every changes on your twitter account will be emailed to you every morning.