Update: as of 12/27/2012, 6pm, Skype mystatus API works again.
Some days ago Skype's mystatus.skype.com has not given the proper API response. Calling http://mystatus.skype.com/sven.kauber.num (or sven.kauber.txt or finally sven.kauber.xml) results in server error or a 1x1 pixel image.
In order to still get the status, the following method can be used:
1. Use url_fopen or cURL to load the status image from the URL http://mystatus.skype.com/balloon/sven.kauber
2. Save the image to a temporary location and get the image from there
3. Each image has different background color, so get just one pixel from the image and RGB values from it
4. Determine the status by using the RGB value combination
Below is the function that is based on the one that was in the earlier Skype-related blog post.
Please note: if you use this function for your purposes, remember to change the value of $tmpFile to match the directory where you are planning to let the function save the temporary status images.
-
public function actionSkypeStatus() {
-
$status = '1'; // default: offline
-
$remoteImg = "http://mystatus.skype.com/balloon/$userName";
-
-
// removing the existing file to write a new one
-
}
-
-
// saving the new temporary image
-
ini_set('user_agent', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:7.0.1) Gecko/20100101 Firefox/7.0.1');
-
}
-
curl_setopt( $ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:7.0.1) Gecko/20100101 Firefox/7.0.1' );
-
-
}
-
else {
-
throw new Exception('Please either enable fopen or cURL!');
-
}
-
-
// getting one pixel from each image and setting status by its color
-
-
switch($color) {
-
case '175,180,180,0':
-
$status = '1'; // offline or invisible
-
break;
-
case '133,197,10,0':
-
$status = '2'; // online
-
break;
-
case '255,204,0,0':
-
$status = '3'; // away
-
break;
-
case '39,59,83,0':
-
$status = '5'; // do not disturb
-
break;
-
}
-
} else {
-
throw new Exception('No GD library available!');
-
}
-
}
-
-
echo $status;
-
}
-
}
Perfect, I modified a little bit the script to use with multiple users and some adjustments.
http://pastebin.com/jFcKcfG1
Use: actionSkypeStatus(USER)
return an array with the status code and the status text.
Thanks, Julien!
How does this work for Skype names that use Windows Live IDs? As far as I am aware, they use a 'live:' prefix in the username, but the page, when I include the 'live:' prefix, returns a 404 error. Without the 'live:' prefix returns me a '1' profile, although my account is set to display my status online.
Nate, thank you for the comment. This is certainly something that needs to be checked as the new Windows Live IDs have not been handled at all.