4

Does anyone know of a URL to get your Skype status using JSONP?

I've only found an XML status URL so far (http://mystatus.skype.com/username.xml).

(I'm trying to query Skype using AJAX. Yes, I could use a server-side proxy script to beat the cross-domain limits, but a direct call would be awesome.)

Simon.

Simon East
  • 55,742
  • 17
  • 139
  • 133
  • Have a look here: http://bytes.com/topic/javascript/answers/699791-read-search-text-file-js something similar but grabbing an "offline" / "online" might be easier. – Sphvn Jul 16 '10 at 01:14

3 Answers3

6

Well apparently you can get a text-only version of the status by changing the extension to .txt:

http://mystatus.skype.com/username.txt

It will return "Online" or "Offline". About the Cross-domain AJAX, you can only do it via server and direct call is definitely not allowed.

mauris
  • 42,982
  • 15
  • 99
  • 131
4

You might change the headline to 'JSONP' instead of JSON. That's what you want.

JSONP hijacks cross domain fetches like this to work, without server proxies, by carrying the data in fetches. It's like the most hackish useful technology I come to mind, right now. :)

I nagged Skype about this - the easiest way out would be for their servers to have an official, documented JSONP interface. I hope they'll do that.

In the mean time, this is how I got the problem solved:

$enable_native   = true;
$valid_url_regex = '/^http:\/\/mystatus\.skype\.com\/myuserid.*/';

This allows it to fetch (via curl running on the server) the mystatus.skype.com/myuserid.num (or .txt) information.

  • Fetching from JS with URL:
ba-simple-proxy.php?url=http%3A%2F%2Fmystatus.skype.com%2Fmyuserid.num&mode=native&full_status=1

That's it. Pheeew... :)

akauppi
  • 17,018
  • 15
  • 95
  • 120
3

Also you can retrieve it using PHP

function getSkypeStatus($username) {
    $data = file_get_contents('http://mystatus.skype.com/' . urlencode($username) . '.xml');

    return strpos($data, '<presence xml:lang="en">Offline</presence>') ? 'Offline' : 'Online';
}

OR

function getSkypeStatus($username) {
    $data = file_get_contents('http://mystatus.skype.com/' . urlencode($username) . '.xml');
    preg_match('@<presence xml:lang="en">(.*?)</presence>@i', $data, $match);

    return isset($match[1]) ? $match[1] : 'Error retrieving status';
} 

Cheers!

Thanks to Bradgrafelman from - http://www.phpbuilder.com/board/showthread.php?t=10361050

foxybagga
  • 4,184
  • 2
  • 34
  • 31