function tphp_qq_online( $uin )
{
$reques = "GET /pa?p=1:".$uin.":1 HTTP/1.1rn";
$reques .= "Host: wpa.qq.comrn";
$reques .= "User-Agent: PHP_QQ_SPYrnrn";
if ( !( $socket = socket_create( AF_INET, SOCK_STREAM, SOL_TCP ) ) ) return(-1);
if ( !( socket_connect( $socket, "wpa.qq.com", 80 ) ) ) return(-1);
if ( !( socket_write( $socket, $reques ) ) ) return(-1);
if ( !( $respon = socket_read( $socket, 1024, PHP_BINARY_READ ) ) ) return(-1);;
socket_close( $socket );
$field = explode( "rn", $respon );
for ( $i=0; $i
if ( strncasecmp($field[$i], "Location:", 9) == 0 ) {
if ( strpos( $field[$i], "online") ) {
$ret = 1;
} else if ( strpos( $field[$i], "offline") ) {
$ret = 0;
} else {
$ret = -1;
} // if
break;
} // if
} // for
return( $ret );
}
/* }}} */
echo tphp_qq_online( 561272831 );
?>
|