Grabbing An Expired Twitter Username

Some jerkwad is squatting on the perfect Twitter username for your next project… What do you do? Complain on the basis of a violation of Twitter’s Terms of Service? I don’t think so… that might wake up the absentee user, then you’d never get the name.

If you have access to a shell, try this curl command to send yourself a Direct Message when the Twitter user’s profile page returns an HTTP 404. Substitute the right values for DESIREDUSERNAME, USERNAME and PASSWORD:

curl -Is http://twitter.com/DESIREDUSERNAME | awk '/Status: 404 Not Found/ { system ("curl -u USERNAME:PASSWORD -d \"text=@DESIREDUSERNAME Twitter account is AVAILABLE%21&user=USERNAME\" http://twitter.com/direct_messages/new.xml")}'

Set it and forget it by adding the command to a cronjob using the command:

$ crontab -e

0 * * * * curl -Is http://twitter.com/DESIREDUSERNAME | awk '/Status: 404 Not Found/ { system ("curl -u USERNAME:PASSWORD -d \"text=@DESIREDUSERNAME Twitter account is AVAILABLE%21&user=USERNAME\" http://twitter.com/direct_messages/new.xml")}'

There you go! Every hour, this pure shell script will check if the Twitter user name is still available. If not, you’ll get a Direct Message letting you know… =)

P.S. Not sure what the status is of a Twitter profile page when the Fail Whale makes an appearance. Probably have to modify the AWK script to handle that case. Will keep an eye on it!

One comment on “Grabbing An Expired Twitter Username

Leave a Reply