用于GTalk,MSN(Skype),Facetime(或消息)的Instant Messenger在线状态检查/指示器

时间:2013-04-29 13:08:48

标签: php javascript messenger instant

我想知道是否有办法检查这些即时消息中的任何一个的在线状态(指标):GTalk,MSN(Skype),Facetime(或消息)。

如果我可以获得用户的在线状态,看看他/她是否在线,离开,忙碌,闲置等任何这些即时消息:AIM,GTalk,ICQ,MSN和YAHOO将会很棒。 (如果有其他IM服务提供此类详细信息,请告知我们)。感谢。

我能够通过卷曲到AIM的big.oscar.aol.com,icq的web.icq.com和YAHOO的opi.yahoo.com获得AIM,ICQ和YAHOO的在线状态并解析回复

注意: GTalk曾经有徽章,而且不再可用。这是我正在寻找的一个很好的例子:http://motyar.blogspot.com/2010/04/gtalk-status-checker-with-php.html

1 个答案:

答案 0 :(得分:1)

这将因服务而异。我最近这样做,发现a blog post关于如何为 Skype 执行此操作,但不知道其他人。

代码属于annar2r,我没有做任何代码:

<?php

function get_skype_status($username, $image = false, $icon = false ){
    //creating url
    //if you need small icon
    if($image && $icon)
    {
    /***************************************
        Possible types of images:

        * balloon            - Balloon style 
        * bigclassic        - Big Classic Style 
        * smallclassic        - Small Classic Style 
        * smallicon        - Small Icon (transparent background) 
        * mediumicon        - Medium Icon 
        * dropdown-white    - Dropdown White Background 
        * dropdown-trans    - Dropdown Transparent Background
        ****************************************/
        return "http://mystatus.skype.com/smallicon/".$username;
    }
    //if you need image
    else if($image)
    {
        return "http://mystatus.skype.com/".$username;
    }
    //or just text
    else
    {
    /***************************************
        Possible status  values:
         NUM        TEXT                DESCRIPTION
        * 0     UNKNOWN             Not opted in or no data available. 
        * 1     OFFLINE                 The user is Offline 
        * 2     ONLINE                  The user is Online 
        * 3     AWAY                    The user is Away 
        * 4     NOT AVAILABLE       The user is Not Available 
        * 5     DO NOT DISTURB  The user is Do Not Disturb (DND) 
        * 6     INVISIBLE               The user is Invisible or appears Offline 
        * 7     SKYPE ME                The user is in Skype Me mode
        ****************************************/
        $url = "http://mystatus.skype.com/".$username.".xml";
        //getting contents
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $data = curl_exec($curl);
        curl_close($curl);

        $pattern = '/xml:lang="en">(.*)</';
        preg_match($pattern,$data, $match); 

        return $match[1];   
    }
}

//getting skype status icon
$ico = get_skype_status("ar2rsawseen", true, true);
echo "<p>Skype icon:</p>";
echo "<p><img src='".$ico."'/></p>";

//getting skype status image
$image = get_skype_status("ar2rsawseen", true);
echo "<p>Skype image:</p>";
echo "<p><img src='".$image."'/></p>";

//getting skype status text
$status = get_skype_status("ar2rsawseen");
echo "<p>Skype status:</p>";
echo "<p>".$status."</p>";

?>