QQ.PHP的代码:
<?
error_reporting(E_ALL ^ E_NOTICE);require_once( 'http.inc.php' );
require_once( 'class.Chinese.php');
//成功2xx
define( 'QQ_RETURN_SUCCESS', 200 );
define( 'QQ_LOGIN_SUCCESS', 201 );
define( 'QQ_LIST_NONE', 202 );
define( 'QQ_ADDTOLIST_SUCCESS', 203 );
define( 'QQ_REPLYADD_SUCCESS', 204 );
define( 'QQ_GETMSG_NONE', 205 );//警告3xx
define( 'QQ_ADDTOLIST_NEEDAUTH',300 );
define( 'QQ_ADDTOLIST_REFUSE', 301 );
define( 'QQ_ADDTOLIST_UNKNOWN', 302 );//失败4xx
define( 'QQ_RETURN_FAILED', 400 );
define( 'QQ_LIST_ERROR', 401 );
define( 'QQ_GETMSG_ERROR', 402 );//在线状态
define( 'QQ_STATUS_ONLINE', 10);
define( 'QQ_STATUS_OFFLINE', 20);
define( 'QQ_STATUS_BUSY', 30);//血型
$QQ_DATA_BT = array
(
0 => '',
1 => 'A型',
2 => 'B型',
3 => 'O型',
4 => 'AB型',
5 => '其他'
);//星座
$QQ_DATA_CO = array
(
0 => '',
1 => '水瓶座',
2 => '双鱼座',
3 => '牡羊座',
4 => '金牛座',
5 => '双子座',
6 => '巨蟹座',
7 => '狮子座',
8 => '处女座',
9 => '天秤座',
10 => '天蝎座',
11 => '射手座',
12 => '摩羯座'
);//生肖
$QQ_DATA_SH = array
(
0 => '',
1 => '鼠',
2 => '牛',
3 => '虎',
4 => '兔',
5 => '龙',
6 => '蛇',
7 => '马',
8 => '羊',
9 => '猴',
10 => '鸡',
11 => '狗',
12 => '猪'
);//性别
$QQ_DATA_SX = array
(
0 => '男',
1 => '女'
);class QQClient
{
var $uin;
var $pwd; var $server = '219.133.51.11';
var $port = 8000; var $httpclient;
var $chs = NULL; function QQClient($uin,$pwd)
{
$this->uin = $uin;
$this->pwd = $pwd;
} function encode($str)
/*
说明:把KEY1=VAL1&KEY2=VAL2格式变为数组
*/
{
$arr = explode('&' , $str);
$return = array();
foreach($arr as $k=>$v)
{
list($key,$val) = explode('=',$v);
$return[$key] = $val;
$this->chs = NULL;
}
return $return;
} function utf8_to_gb2312($str)
{
$this->chs = new Chinese("UTF8","GB2312", $str );
return $this->chs->ConvertIT();
} function gb2312_to_utf8($str)
{
$this->chs = new Chinese("GB2312","UTF8", $str );
return $this->chs->ConvertIT();
} function query($str)
{
$this->httpclient = new http( HTTP_V11, true );
$this->httpclient->host = '219.133.51.11';
$this->httpcilent->port = '8000'; $query = $this->encode($str);
$status = $this->httpclient->post( '', $query, '' );
if ( $status == HTTP_STATUS_OK ) {
return $this->httpclient->get_response_body();
}
else
{
print_r($this->httpclient);
return false;
}
$this->httpclient->disconnect();
unset($this->httpclient);
} function split_str($str)
{
$arr = explode("," , $str);
if($arr[count($arr)-1] == NULL)
{
unset($arr[count($arr)-1]);
}
return $arr;
} function login()
{
//登陆
//VER=1.1&CMD=Login&SEQ=&UIN=&PS=&M5=1&LC=9326B87B234E7235
$str = "VER=1.1&CMD=Login&SEQ=".rand(1000,9000)."&UIN=".$this->uin."&PS=".md5($this->pwd)."&M5=1&LC=9326B87B234E7235";
$return = $this->encode($this->query($str));
if($return['RES']==0 and $return['UIN'] == $this->uin)
{
//返回成功
if($return['RS']==0)
{
//登陆成功
return QQ_LOGIN_SUCCESS;
}
else
{
//登陆失败
$GLOBALS['QQ_ERROR_MSG'] = $this->utf8_to_gb2312($return['RA']);
return QQ_LOGIN_FAILED;
}
}
else
{
//返回失败
return QQ_RETURN_FAILED;
}
} function getFriendsList()
{
//得到好友列表
//VER=1.1&CMD=List&SEQ=&UIN=&TN=160&UN=0
$str = "VER=1.1&CMD=List&SEQ=".rand(1000,9000)."&UIN=".$this->uin."&TN=160&UN=0";
$return = $this->encode($this->query($str));
if($return['RES']==0 and $return['UIN'] == $this->uin)
{
//返回成功
return $this->split_str($return['UN']);
}
else
{
//返回失败
return QQ_RETURN_FAILED;
}
} function getOnlineList()
{
//得到在线好友列表
//VER=1.1&CMD=Query_Stat&SEQ=&UIN=&TN=50&UN=0
$str = "VER=1.1&CMD=Query_Stat&SEQ=".rand(1000,9000)."&UIN=".$this->uin."&TN=50&UN=0";
$return = $this->encode($this->query($str));
if($return['RES']==0 and $return['UIN'] == $this->uin)
{
//返回成功
if($return['SN'] > 0)
{
//在线好友数>0
$uns = $this->split_str($return['UN']); //号码列表
$nks = $this->split_str($return['NK']); //昵称列表
$sts = $this->split_str($return['ST']); //状态列表
$fcs = $this->split_str($return['FC']); //头像列表
$error = 0;
((count($uns)==count($nks))==(count($sts)==count($fcs)))==(count($nks)==count($sts)) ?
$num = count($uns)
:
$error = 1;
;
if($error == 1) return QQ_LIST_ERROR;
$arr = array();
for($i=0;$i<$num;$i++)
{
$arr[] = array(
"UN" => $uns[$i] ,
"NK" => $this->utf8_to_gb2312($nks[$i]) ,
"ST" => $sts[$i] ,
"FC" => $fcs[$i]
);
}
return ($arr);
}
else
{
//在线好友数<=0
return QQ_LIST_NONE;
}
}
else
{
//返回失败
return QQ_RETURN_FAILED;
}
}
<?
error_reporting(E_ALL ^ E_NOTICE);require_once( 'http.inc.php' );
require_once( 'class.Chinese.php');
//成功2xx
define( 'QQ_RETURN_SUCCESS', 200 );
define( 'QQ_LOGIN_SUCCESS', 201 );
define( 'QQ_LIST_NONE', 202 );
define( 'QQ_ADDTOLIST_SUCCESS', 203 );
define( 'QQ_REPLYADD_SUCCESS', 204 );
define( 'QQ_GETMSG_NONE', 205 );//警告3xx
define( 'QQ_ADDTOLIST_NEEDAUTH',300 );
define( 'QQ_ADDTOLIST_REFUSE', 301 );
define( 'QQ_ADDTOLIST_UNKNOWN', 302 );//失败4xx
define( 'QQ_RETURN_FAILED', 400 );
define( 'QQ_LIST_ERROR', 401 );
define( 'QQ_GETMSG_ERROR', 402 );//在线状态
define( 'QQ_STATUS_ONLINE', 10);
define( 'QQ_STATUS_OFFLINE', 20);
define( 'QQ_STATUS_BUSY', 30);//血型
$QQ_DATA_BT = array
(
0 => '',
1 => 'A型',
2 => 'B型',
3 => 'O型',
4 => 'AB型',
5 => '其他'
);//星座
$QQ_DATA_CO = array
(
0 => '',
1 => '水瓶座',
2 => '双鱼座',
3 => '牡羊座',
4 => '金牛座',
5 => '双子座',
6 => '巨蟹座',
7 => '狮子座',
8 => '处女座',
9 => '天秤座',
10 => '天蝎座',
11 => '射手座',
12 => '摩羯座'
);//生肖
$QQ_DATA_SH = array
(
0 => '',
1 => '鼠',
2 => '牛',
3 => '虎',
4 => '兔',
5 => '龙',
6 => '蛇',
7 => '马',
8 => '羊',
9 => '猴',
10 => '鸡',
11 => '狗',
12 => '猪'
);//性别
$QQ_DATA_SX = array
(
0 => '男',
1 => '女'
);class QQClient
{
var $uin;
var $pwd; var $server = '219.133.51.11';
var $port = 8000; var $httpclient;
var $chs = NULL; function QQClient($uin,$pwd)
{
$this->uin = $uin;
$this->pwd = $pwd;
} function encode($str)
/*
说明:把KEY1=VAL1&KEY2=VAL2格式变为数组
*/
{
$arr = explode('&' , $str);
$return = array();
foreach($arr as $k=>$v)
{
list($key,$val) = explode('=',$v);
$return[$key] = $val;
$this->chs = NULL;
}
return $return;
} function utf8_to_gb2312($str)
{
$this->chs = new Chinese("UTF8","GB2312", $str );
return $this->chs->ConvertIT();
} function gb2312_to_utf8($str)
{
$this->chs = new Chinese("GB2312","UTF8", $str );
return $this->chs->ConvertIT();
} function query($str)
{
$this->httpclient = new http( HTTP_V11, true );
$this->httpclient->host = '219.133.51.11';
$this->httpcilent->port = '8000'; $query = $this->encode($str);
$status = $this->httpclient->post( '', $query, '' );
if ( $status == HTTP_STATUS_OK ) {
return $this->httpclient->get_response_body();
}
else
{
print_r($this->httpclient);
return false;
}
$this->httpclient->disconnect();
unset($this->httpclient);
} function split_str($str)
{
$arr = explode("," , $str);
if($arr[count($arr)-1] == NULL)
{
unset($arr[count($arr)-1]);
}
return $arr;
} function login()
{
//登陆
//VER=1.1&CMD=Login&SEQ=&UIN=&PS=&M5=1&LC=9326B87B234E7235
$str = "VER=1.1&CMD=Login&SEQ=".rand(1000,9000)."&UIN=".$this->uin."&PS=".md5($this->pwd)."&M5=1&LC=9326B87B234E7235";
$return = $this->encode($this->query($str));
if($return['RES']==0 and $return['UIN'] == $this->uin)
{
//返回成功
if($return['RS']==0)
{
//登陆成功
return QQ_LOGIN_SUCCESS;
}
else
{
//登陆失败
$GLOBALS['QQ_ERROR_MSG'] = $this->utf8_to_gb2312($return['RA']);
return QQ_LOGIN_FAILED;
}
}
else
{
//返回失败
return QQ_RETURN_FAILED;
}
} function getFriendsList()
{
//得到好友列表
//VER=1.1&CMD=List&SEQ=&UIN=&TN=160&UN=0
$str = "VER=1.1&CMD=List&SEQ=".rand(1000,9000)."&UIN=".$this->uin."&TN=160&UN=0";
$return = $this->encode($this->query($str));
if($return['RES']==0 and $return['UIN'] == $this->uin)
{
//返回成功
return $this->split_str($return['UN']);
}
else
{
//返回失败
return QQ_RETURN_FAILED;
}
} function getOnlineList()
{
//得到在线好友列表
//VER=1.1&CMD=Query_Stat&SEQ=&UIN=&TN=50&UN=0
$str = "VER=1.1&CMD=Query_Stat&SEQ=".rand(1000,9000)."&UIN=".$this->uin."&TN=50&UN=0";
$return = $this->encode($this->query($str));
if($return['RES']==0 and $return['UIN'] == $this->uin)
{
//返回成功
if($return['SN'] > 0)
{
//在线好友数>0
$uns = $this->split_str($return['UN']); //号码列表
$nks = $this->split_str($return['NK']); //昵称列表
$sts = $this->split_str($return['ST']); //状态列表
$fcs = $this->split_str($return['FC']); //头像列表
$error = 0;
((count($uns)==count($nks))==(count($sts)==count($fcs)))==(count($nks)==count($sts)) ?
$num = count($uns)
:
$error = 1;
;
if($error == 1) return QQ_LIST_ERROR;
$arr = array();
for($i=0;$i<$num;$i++)
{
$arr[] = array(
"UN" => $uns[$i] ,
"NK" => $this->utf8_to_gb2312($nks[$i]) ,
"ST" => $sts[$i] ,
"FC" => $fcs[$i]
);
}
return ($arr);
}
else
{
//在线好友数<=0
return QQ_LIST_NONE;
}
}
else
{
//返回失败
return QQ_RETURN_FAILED;
}
}
另外现在挂机成风,QQ密码已经不值钱了这个程序需要在Console里面运行,并且最好把php.ini中的程序运行超时调大
/*
QQ挂机程序
使用Hackfan的QQ Client作者:Hackfan
来源:http://blog.hackfan.net/
2005.8.19
*/
require_once("qq.php");
$qqs = array
(
"QQ号码"=>"密码"
);foreach($qqs as $k=>$v)
{
$qq[$k] = new QQClient($k,$v);
//登陆
echo "号码".$k."正在登陆...";
switch($qq[$k] -> login())
{
case QQ_LOGIN_SUCCESS:
echo "号码".$k."登陆成功,即将进入挂机状态...";
break;
case QQ_RETURN_FAILED:
echo "号码".$k."在登陆时,服务器返回错误,将不再挂机";
unset($qq[$k]);
break;
default:
echo "号码".$k."登陆失败,原因:".$QQ_ERROR_MSG.",将不再挂机";
unset($qq[$k]);
break;
}
echo "\n";
}while(1)
{
sleep(30);//每30秒刷新一次挂机号码
foreach($qqs as $k=>$v)
{
$qq[$k]->login();
echo "刷新了".$k."\n";
}
echo "工作完成,休息5秒\n\n";
}?>
然后进入程序所在目录
比如
d:
cd qqclient运行:
php sample.php然后程序就执行了。这个时候,你打开你的大号,对小号(应该是在线的离开状态)说:
你好
上线
离开
或者其他一些话
你看看Console
zairwolf(君子兰):
运行超级损耗时间。到现在还没执行完。
你用的fputs方式。有没考虑过socksopen?
*******/首先,你如果使用WebServer运行,我使用了while(1),它是不会输出任何内容的
另外,程序是一个后台啊。关于HTTP的东西,我用的是别人的类,具体的技术我不去过问了,只要帮我完成和HTTP服务器的交流就可以
隐身我也研究过,按照道理代码应该是40,不过好像没有成功
$qnum=$qnum?$qnum:'239845259';
$qtnum=$qtnum?$qtnum:'200870128';
echo("<form action=test.php method=post>q号码:<input type=text name=qnum value='$qnum'><br>q密码:<input type=password name=qpwd value='$qpwd'><br>发送对象号码:<input type=text name=qtnum value='$qtnum'><br><textarea name=qcon>$qcon</textarea><br><input type=submit value=' 提交 '></form>");
require_once("qq.php");//初始化
if(!$qcon) exit;
$qq = new QQClient($qnum,$qpwd);$qq -> login();switch($qq -> sendMsg($qtnum,addslashes($qcon)))
{
case QQ_RETURN_SUCCESS :
echo "<font color=red>发送成功</font>";
break;
case QQ_RETURN_FAILED :
echo "<font color=blue>发送失败</font>";
exit;
break;
}
?>
因为1个QQ每分钟只要发送1KB都不到的HTTP POST数据包
http://www.ckong.cn/qqclient/test1.php现在还没做完。只能看消息,没法回复和添加好友删除好友什么的高级功能。
大家可以看看http://www.dawang.net/qq
http://bbs.chinaunix.net/forum/27/050821/597209.html