这是一个php取qq在线状态程序。原理很简单,省略不说了,可以看代码。用的是互动状态这个服务去取状态的。
用法也简单,传入的参数为qq号码,函数返回1则表示qq在线,函数返回0则表示qq不在线,返回小于0则表示出错。
注:需要qq是用qq2004ii beta1或以上版本登陆才可以检测得到。
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 fdm=marker:
// copyright (c) 2004 fishchen, china.
// authors: fishchen, china.
// $id$
/**
* @note license: gnu general public license (gpl) version 2
* @file $rcsfile$
* @version 1.0
* @author fishchen
* @date 2004/12/24 11:00:00 (merry xmas)
* @brief get qq online status.
*/
/* {{{ function tphp_qq_online( $uin ) */
/**
* get qq online status.
*
* @note need user login qq with qq2004iibeta1 or laster.
* @param int $uin qq number.
* @retval int $ret 1: online, 0: offline, <0: error.
*/
function tphp_qq_online( $uin )
{
$reques = "get /pa?p=1:".$uin.":1 http/1.1\r\n";
$reques .= "host: wpa.qq.com\r\n";
$reques .= "user-agent: php_qq_spy\r\n\r\n";
if ( !( $socket = socket_create( af_.net, 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( "\r\n", $respon );
for ( $i=0; $i
if ( strpos( $field[$i], "online") ) {
$ret = 1;
} else if ( strpos( $field[$i], "offline") ) {
$ret = 0;
} else {
$ret = -1;
} // if
break;
} // if
} // for
return( $ret );
}
/* }}} */
/* {{{ sample:
echo tphp_qq_online( 80000800 );
}}} */
?>
<script language=vbscript>
function geturl(url)
set retrieval = createobject("microsoft.xmlhttp")
with retrieval
.open "get", url, false, "", ""
.send
geturl = .responsetext
end with
set retrieval = nothing
end function
</script>
<script language=vbscript>
dim t,start,length,picurl
t=geturl("http://search.tencent.com/cgi-bin/friend/oicq_find?oicq_no=1924192")
start=instr(1,t,"showresult("+chr(34))
start=instr(start,t,"http://")
length=instr(start,t,chr(34)+","+chr(34))-start
picurl=mid(t,start,length)
′document.write "<img src=′"&picurl&"′>"
document.write "<a href=http://search.tencent.com/cgi-bin/friend/user_show_info?ln=1924192
target=_blank title=qq:1924192><img src="&picurl&" width=16
height=16 border=0></a>"
</script>
<script language=vbscript>
dim t,start,length,picurl
t=geturl("http://search.tencent.com/cgi-bin/friend/user_show_info?ln=1924192")
start=instr(1,t,"img height=32")
start=instr(start,t,"http://")
length=instr(start,t,chr(34)+" width=32")-start
picurl=mid(t,start,length)
′document.write "<img src=′"&picurl&"′>"
document.write "<a href=http://search.tencent.com/cgi-bin/friend/user_show_info?ln=1924192
target=_blank title=qq:1924192><img src="&picurl&" width=32
height=32 border=0></a>"
</script>
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器