I’ve been trying to grab a Twitter screenname that people continually register and do not use. Twitter eventually deletes it, but I suppose it is in high enough demand that someone else registers it right away (and then continues to never use it). Wrote up a quick and dirty php script to check the Twitter API to see if a screenname exists and if it doesn’t, shoot a short an email. I’ve been using changedetection to roughly do the same thing but it has fallen short on two counts: the first is that it reports follower count changes, and second it only runs once a day and this hasn’t been fast enough for me to grab my desired screen name.

You can set this script to run via cron at any desired interval, I’ve set it to run every 30 minutes for me. Test with sample information to make sure it works under your setup. I’m using the default mail() function, and I also included some json decoding in there so you could also use this script to play around with decoding a user’s information in PHP.

[cc lang=”php” lines=”100″]

If you are running it from cron, add the sample entry:

0 * * * * /usr/bin/php /path/to/script.php

The above would run the script every hour on the hour.

Of course you can easily modify this sample code if you are looking to do any kind of similar checking in your web app. If you find this kind of script useful, please let me know!

  1.  Great post. I modded this to find my @G64 handle. I thank you in the explanation of my version here: http://goo.gl/9u4dD

  2. Great article. Unfortunately the twitter username I want is not being used but it is also not available yet. I guess they hold onto them for sometime and then randomly release them. The problem is that a vacant username and an unused username that is still not available give the same json response. Do you know how one might check if the username is available too? Doesn’t seem like you can create a twitter account or change your username via the API….at least not that I have found

  3. by adding an @ sign in front of any command you can disable the error too.. @file_get_contents

Comments are closed.

You May Also Like

Simple Redirect Subdomain to a Directory

If you are running Apache for your web server, and mod_rewrite is…

Last Modified Date or Time on WordPress Template Page

I couldn’t readily find an answer to this question via the google.…

Visual.Syntax is my choice for code highlighting

I am using the Visual.Syntax code highlighting plugin by Matthew Delmarter. There…