About a week ago or so my girlfriend Kim decided to create a Twitter account for our dog Bailey. She's been updating it and occasionally, I'll update it, but I didn't really want to update two Twitter accounts, so I decided to figure out a way to let Bailey Twitter herself. I wanted Bailey to be able to upload pictures and messages when she moves around the house. I have a webcam that I don't use very often, so I decided to write a perl script that would upload pictures to TwitPic.com and update Twitter with the TwitPic link. I also wanted this to be triggered from motion detection, so I also decided to use a great Linux application appropriately named Motion, but I digress.
First the perl script. I decided to make the act of uploading the picture and updating Twitter it's own self contained script so it could be used on it's own or for other things and it works on Windows, Linux, and Mac. I don't have a place to host the script, so here it is (just copy and paste it):
You can set default values in the script and then all you need to do is pass in a picture, or you can use the command line options to override all the options. I set up defaults for everything, and have been just calling the script with the --picture option and the --message option.
Now all you need to do is set up your webcam application. As I said, I used Motion, so I'll show you how to set that up, but I'm sure you could do this with WebCamXP or something. From the command line do the following:
- sudo apt-get install motion
- mkdir ~/.motion
- sudo cp /etc/motion/motion.conf ~/.motion
- sudo chown $USER ~/.motion/motion.conf
- vim ~/.motion/motion.conf
Then you can just edit the conf to your liking. You can enable/disable things, capture movies, and a ton of other stuff that I don't really know much about. Or you can just copy and paste my config. I turned off the webserver and tweaked a few other things, but most of the stuff is the same. The one key line, is the line that calls the updateTwitter.pl script. My settings assume that your script is located at
This script will upload pictures very quickly to your twitter account, and spam the hell out of people when motion is found, so you'll need to adjust the frame rate/sensitivity.