DIY Qwitter app

If you know about the Qwitter service, then you may also know what people say about it – that it plain doesn’t work. So for my first Twitter app, I decided to make one that does.

I have been made aware since then that there is also Twitdiff, although I haven’t tried it at time of writing.

If you don’t know about Qwitter, it’s a service that monitors your Twitter followers and emails you if someone unfollows you. My app currently tweets the notification instead, so everyone will know you’ve been qwit.

I’m not offering my app as a public service [yet] I knocked it up in 2 hours and if you know what you’re doing with a LAMP set-up you can download it and run it yourself.

» Download qwitter 0.1.2
Requires PHP >= 5.2.x  + json extension, MySQL >= 5.0.45

INSTALL

Ensure you have a PHP binary at /usr/bin/php and check the version is suitable

$ which php
/usr/bin/php
$ /usr/bin/php --version
PHP 5.2.x (cli) (built: ..........)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

Unzip the download, and ensure it’s executable:

$ tar -xvzf qwitter-0-1.tar.gz
$ cd qwitter-0-1
$ chmod u+x qwitter

Configure it for your Twitter account with these two constants:

define( 'TWITTER_USER', '' );
define( 'TWITTER_PASSWORD', '' );

Configure it for your MySQL server. These constants are the default:

define('PLUG_DB_NAME', 'qwitter');
define('PLUG_DB_USER', 'qwitter');
define('PLUG_DB_PASS', '');
define('PLUG_DB_HOST', 'localhost');
define('PLUG_DB_PORT', '3306');

Create the database table.

CREATE TABLE `qwitter_followers` (
`id` varchar(11) collate utf8_unicode_ci NOT NULL,
`modified` timestamp NULL default NULL,
`created` timestamp NOT NULL default '0000-00-00 00:00:00',
`unfollowed` timestamp NULL default NULL,
PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

Note that you can configure the table name prefix, so you can run multiple qwitters on the same data source. See QWITTER_TABLE_PREFIX constant

USAGE

You should test it works by simply running it, but the only way the app can do its job for real is to be run frequently – the more frequent the better. To set up a cron job and run the app every 5 minutes, create a crontab entry like this:

*/5   *   *   *   *   /path/to/qwitter >/dev/null 2>&1

If you don’t know how to set up a cronjob, you’d better Google it.

Note that if someone follows and unfollows you within this time window, you won’t be informed. The app needs to see the follower at least once before it will notice that you’ve been since unfollowed.

CHANGELOG

1.0.1
Added QWITTER_TABLE_PREFIX config
Fixed loophole where blocked users were considered qwitters
1.0.2
Added QWITTER_NOTIFY to support emailing of notification

TODO

  1. Check missing followers against your block list. Currently blocking a user raises a notification. todone
  2. Implement OAuth, so this can be offered as a service