首页 >后端开发 >php教程 >试试看这个判断ICQ是否在线的代码好用吗?_PHP

试试看这个判断ICQ是否在线的代码好用吗?_PHP

WBOY
WBOY原创
2016-06-01 12:28:41947浏览

  
function get_status($uin)
{  
    $fp = fsockopen ("wwp.icq.com", 80, &$errno, &$errstr, 30);  
    if(!$fp)
    {  
        echo "$errstr ($errno)
\n";  
    }
    else
    {
        fputs($fp, "GET /scripts/online.dll?icq=$uin&img=5 HTTP/1.0\n\n");  
        $do = 'yes';  
        while(!feof($fp))
        {
            $line = fgets ($fp,128);
            $do = ($do == 'yes')?'yes':(eregi("^GIF89", $line))?'yes':'no';
            //echo $line;
            
            if($do == 'yes')
            {
                if(ereg("@", $line))
                {
                    return 'online';  
                }
                elseif(ereg("醱", $line))
                {  
                    return 'offline';  
                }
                elseif(ereg("S", $line))
                {
                    return 'disabled';  
                }
            }
            
        }
        fclose($fp);  
    }  
    return 'unknown!';  
}


$uin="72485936";  // sonymusic 的ICQ,呵呵。
echo get_status($uin);
// offline
// HTTP/1.0 200 OK Content-type: image/gif GIF89a(幵觮R瑴螗#%醱` ?0? 靦Wb缒unknown
// online
// HTTP/1.0 200 OK Content-type: image/gif GIF89a(幵觮R 瑴螗#%?@ ?0?U靦WB鐒unknown
?>  

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn