It’s simple to display your Skype status on your website or blog, the nice people at Skype even have a web page that will generate the code to do it for you.
What they don’t offer, however, is a way to customise the images displayed for your status so if you want something different you’re buggered.
So, with the (not inconsiderable) help of one of my old Enemy Territory clan-mates, Dave Workman, I’ve done it myself.
<?php
$file = "http://mystatus.skype.com/stuartparr.txt";
system("wget -N $file");
$handle = fopen("stuartparr.txt", "r");
$string = fgets($handle);
$before = ‘<a href="skype:stuartparr">’;
$after = "</a>";
if ($string=="Offline" || $string=="Unknown" || $string=="Do Not Disturb")
{
$before="";
$after="";
}
echo($before.'<img src="http://www.wonkosworld.co.uk/images/skype/’.$string.’.png" />’.$after);
?>
Skype offer various ways of displaying your status, one of which is a text file with your status in it. You access this via the url http://mystatus.skype.com/<username>.txt. The file above tells the operating system to run wgets to retrieve the file at that location. This will only work on a Linux/Unix server unless your Windows server has wgets installed.
After the operating system gets the file, the php script opens the file and then gets the contents and stores them in $string. If the status of Skype is Offline or Unknown then there is no point linking the status icon to Skype you so the next couple of lines check the status and blank out the $quot;before" and "after" text so a link isn’t generated.
The final line actually displays the icon by inserting the contents of the text file into a url for an image.
I’ve never thought of using system commands like wget for getting web pages.. I have always used php’s file_get_contents function:
http://uk2.php.net/manual/en/function.file-get-contents.php
The files at skype.com won’t open like that. I’m told by my guru that it’s because the there are no headers or something along those lines.