Created
May 23, 2011 05:14
-
-
Save jbhannah/986254 to your computer and use it in GitHub Desktop.
Skype status PHP script for use with AJAX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header('Content-type: application/json'); | |
if ( array_key_exists('username', $_GET) ) | |
$user = $_GET['username']; | |
else | |
$user = ""; | |
$curl = curl_init("http://mystatus.skype.com/${user}.num"); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); | |
$n = curl_exec($curl); | |
if ( !is_numeric($n) ) | |
$n = 0; | |
$s = array(1 => 'offline', 2 => 'online', 3 => 'away', 5 => 'do_not_disturb'); | |
if ( array_key_exists($n, $s) ) | |
$status = $s[$n]; | |
else | |
$status = 'unknown'; | |
echo json_encode(array("username" => $user, "status" => $status)); | |
curl_close($curl); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi