Twitter - sending webcam image as profile picture
Posted: Mon 09 Nov 2009 5:53 pm
In a moment of terminal boredom I thought 'how can I get Cumulus to twitter my weather station data?' - the answer to this proved amazingly easy thanks to Steve's great software and creating a slightly custom feed was also a breeze.
I then considered how to put a web cam image up there as well. On my page at Weather Underground I have a web cam feed http://www.wunderground.com/weatherstat ... =IBERKSRE4 so how could I do something like this with Twitter?
First thought, use TwitPic and upload an image and then add a link to the Cumulus twitter feed, problem - twitter is a micro blog and not really enough space to tweet the weather and a link to the current web cam picture.
Second thought, use the Twitter profile picture, update that from the web cam image every so many minutes, then whenever the weather is tweeted it will have a reasonably upto date picture of the weather to go with it. How hard could it be?
Answer, pretty simple.
Assumption : you will, as I am, already have to have something that grabs your web cam image and can update a single image file on your Weather Station PC. I use YawCam for this, its free, simple and first class. It feeds, via FTP, a web cam image to WeatherUnderground (and will do so to my web site if I ever get time to work on it), allows me to overlay text on the image. Now it also allows me to save the image file on the PC to then send to Twitter
Step 1. The Twitter API looks simple enough, a line of code using CURL (download and install it on your PC) is enough to grab the image file and update your Twitter profile picture
(The code above is a single line)
Set twitteruser and password accordingly
Set imagename accordingly
Put this into a batch file, I called mine twitprofile.bat
I put the CURL program and my twitprofile.bat into the Cumulus program folder and had YawCam write the web cam image there too, just to keep things simple and avoid file location paths, if you don't then make sure you specify full paths to things.
Step 2. Set up a Scheduled Task in Windows to run twitprofile.bat every n minutes, base it on how frequently you want the profile image to be updated from yoru web cam, I set mine to 20 minutes, the same period as my weather Twitter feed from Cumlus
Step 3. Have a beer, this step is vital and should always be observed even if steps 1 and 2 lead to failure (if they do keep trying until it works or you are too drunk to care)
now my weather station tweets the weather with a profile picture from my web cam, all updating 3 times an hour (when I have the PC on of course)
http://twitter.com/60Redwood
Not much to see at night of course, next step is to make it use a default image for times when its dark (and YawCam isnt sending an update), this may be something YawCam can do or maybe its another simple bit of CURLing
Steve
I then considered how to put a web cam image up there as well. On my page at Weather Underground I have a web cam feed http://www.wunderground.com/weatherstat ... =IBERKSRE4 so how could I do something like this with Twitter?
First thought, use TwitPic and upload an image and then add a link to the Cumulus twitter feed, problem - twitter is a micro blog and not really enough space to tweet the weather and a link to the current web cam picture.
Second thought, use the Twitter profile picture, update that from the web cam image every so many minutes, then whenever the weather is tweeted it will have a reasonably upto date picture of the weather to go with it. How hard could it be?
Answer, pretty simple.
Assumption : you will, as I am, already have to have something that grabs your web cam image and can update a single image file on your Weather Station PC. I use YawCam for this, its free, simple and first class. It feeds, via FTP, a web cam image to WeatherUnderground (and will do so to my web site if I ever get time to work on it), allows me to overlay text on the image. Now it also allows me to save the image file on the PC to then send to Twitter
Step 1. The Twitter API looks simple enough, a line of code using CURL (download and install it on your PC) is enough to grab the image file and update your Twitter profile picture
Code: Select all
curl -u twitteruser:password -H "Expect:" -F image=@"imagename.jpg;type=image/jpg" http://twitter.com/account/update_profile_image.xmlSet twitteruser and password accordingly
Set imagename accordingly
Put this into a batch file, I called mine twitprofile.bat
I put the CURL program and my twitprofile.bat into the Cumulus program folder and had YawCam write the web cam image there too, just to keep things simple and avoid file location paths, if you don't then make sure you specify full paths to things.
Step 2. Set up a Scheduled Task in Windows to run twitprofile.bat every n minutes, base it on how frequently you want the profile image to be updated from yoru web cam, I set mine to 20 minutes, the same period as my weather Twitter feed from Cumlus
Step 3. Have a beer, this step is vital and should always be observed even if steps 1 and 2 lead to failure (if they do keep trying until it works or you are too drunk to care)
now my weather station tweets the weather with a profile picture from my web cam, all updating 3 times an hour (when I have the PC on of course)
http://twitter.com/60Redwood
Not much to see at night of course, next step is to make it use a default image for times when its dark (and YawCam isnt sending an update), this may be something YawCam can do or maybe its another simple bit of CURLing
Steve