PHP to achieve basic QQ function: QQ robot

Source: Internet
Author: User
Tags format chr current time explode http request interface log rand

1. Research Notes

Tencent in Tqq.tencent.com 8000 has a use of HTTP QQ interface, through this interface, you can do some basic operations, such as: Landing, log out, change the landing status (on-line, busy, offline, stealth), add delete friends, view friend information, send authentication information (Accept being added as a friend, apply to add each other as friends, refuse to be added as friends), send and receive user messages, System information.

I am currently studying the 1.1 version of the HTTP QQ protocol, research is the results of micro-thread, dare not say what beyond, but more detailed and accurate.

2, Interface Description:

Interface Location: tqq.tencent.com:8000

Communication protocol: HTTP

Data transfer method: POST

HTTP request Format:

POST http/1.1

host:tqq.tencent.com:8000

Content-type:text/plain; Charset=utf-8

Content-length: Length

Connection:close

Data

Where the length is the length of the data, the format of the data:

ver=1.1&cmd= command &seq= Mark &uin=qq .....

The above 4 parameters are required for every request. Among them, Ver represents the version of the Protocol, currently 1.1, said 1.2 has been out, this disorderly writing, the server returned null; CMD for the operation of the instructions, there are login, List, Query_stat, GetInfo, Addtolist, Ack_addtolist, Delfromlist, Change_stat, Getmsgex, Cltmsg, Logout; SEQ is the current request of the tag, to prevent repeated transmission, can use the current time, also can use random number; UIn is the QQ number that is currently executing the operation. But different cmd also need different parameters, below I will publish my research results.

3. Research methods:

I am not satisfied with the information on the Internet, I write the program, send multiple requests of the same cmd different parameters, according to the return of the server, to make judgments. Interested friends can refer to, here can skip.

Below I publish my probing code (PHP):


?

$uin = "QQ number";

$PWD = MD5 ("QQ password");

Landing test

$poststring [] = "ver=1.1&cmd=login&seq=". Rand (1000,9000). &uin= ". $uin." &ps= ". $pwd." &m5=1&lc=9326b87b234e7235 ";

Note: Landing test can not be done at the same time, must wait until the server think QQ disconnected, can test, or the results are not credible

/*******

$poststring [] = "ver=1.1&cmd=login&seq=". Rand (1000,9000). &uin= ". $uin." &ps= ". $pwd." &m5=0&lc=9326b87b234e7235 ";

$poststring [] = "ver=1.1&cmd=login&seq=". Rand (1000,9000). &uin= ". $uin." &ps= ". $pwd." &m5=1&lc=9326b87b234e7235 ";

$poststring [] = "ver=1.1&cmd=login&seq=". Rand (1000,9000). &uin= ". $uin." &ps= ". $pwd." &m5=2&lc=9326b87b234e7235 ";

$poststring [] = "ver=1.1&cmd=login&seq=". Rand (1000,9000). &uin= ". $uin." &ps= ". $pwd." &m5=3&lc=9326b87b234e7235 ";

$poststring [] = "ver=1.1&cmd=login&seq=". Rand (1000,9000). &uin= ". $uin." &ps= ". $pwd." &m6=1&lc=9326b87b234e7235 ";

$poststring [] = "ver=1.1&cmd=login&seq=". Rand (1000,9000). &uin= ". $uin." &ps= ". $pwd." &m6=1&lc=1223423545756679 ";

*******/

Get a buddy list

$poststring [] = "ver=1.1&cmd=list&seq=". Rand (1000,9000). &uin= ". $uin;

$poststring [] = "ver=1.1&cmd=list&seq=". Rand (1000,9000). &uin= ". $uin." &tn=0 ";

$poststring [] = "ver=1.1&cmd=list&seq=". Rand (1000,9000). &uin= ". $uin." &tn=160 ";

$poststring [] = "ver=1.1&cmd=list&seq=". Rand (1000,9000). &uin= ". $uin." &un=0 ";

$poststring [] = "ver=1.1&cmd=list&seq=". Rand (1000,9000). &uin= ". $uin." &un= ". Rand (1,10);

$poststring [] = "ver=1.1&cmd=list&seq=". Rand (1000,9000). &uin= ". $uin." &tn=0&un=0 ";

$poststring [] = "ver=1.1&cmd=list&seq=". Rand (1000,9000). &uin= ". $uin." &tn=160&un=0 ";

$poststring [] = "ver=1.1&cmd=list&seq=". Rand (1000,9000). &uin= ". $uin." &tn=160&un=0 ";

$poststring [] = "ver=1.1&cmd=list&seq=". Rand (1000,9000). &uin= ". $uin." &tn= ". Rand (1,200)." &un=0 ";

$poststring [] = "ver=1.1&cmd=list&seq=". Rand (1000,9000). &uin= ". $uin." &tn= ". Rand (1,200)." &un=0 ";

$poststring [] = "ver=1.1&cmd=list&seq=". Rand (1000,9000). &uin= ". $uin." &tn= ". Rand (1,200)." &un=0 ";

$poststring [] = "ver=1.1&cmd=list&seq=". Rand (1000,9000). &uin= ". $uin." &tn=0&un= ". Rand (1,10);

$poststring [] = "ver=1.1&cmd=list&seq=". Rand (1000,9000). &uin= ". $uin." &tn=0&un= ". Rand (1,10);

$poststring [] = "ver=1.1&cmd=list&seq=". Rand (1000,9000). &uin= ". $uin." &tn=0&un= ". Rand (1,10);

$poststring [] = "ver=1.1&cmd=list&seq=". Rand (1000,9000). &uin= ". $uin." &tn=0&un=106814 ";

Get online list

$poststring [] = "ver=1.1&cmd=query_stat&seq=". Rand (1000,9000). &uin= ". $uin;

$poststring [] = "ver=1.1&cmd=query_stat&seq=". Rand (1000,9000). &uin= ". $uin." &tn=0 ";

$poststring [] = "ver=1.1&cmd=query_stat&seq=". Rand (1000,9000). &uin= ". $uin." &tn=160 ";

$poststring [] = "ver=1.1&cmd=query_stat&seq=". Rand (1000,9000). &uin= ". $uin." &un=0 ";

$poststring [] = "ver=1.1&cmd=query_stat&seq=". Rand (1000,9000). &uin= ". $uin." &un= ". Rand (1,10);

$poststring [] = "ver=1.1&cmd=query_stat&seq=". Rand (1000,9000). &uin= ". $uin." &tn=0&un=0 ";

$poststring [] = "ver=1.1&cmd=query_stat&seq=". Rand (1000,9000). &uin= ". $uin." &tn=160&un=0 ";

$poststring [] = "ver=1.1&cmd=query_stat&seq=". Rand (1000,9000). &uin= ". $uin." &tn=160&un=0 ";

$poststring [] = "ver=1.1&cmd=query_stat&seq=". Rand (1000,9000). &uin= ". $uin." &tn= ". Rand (1,200)." &un=0 ";

$poststring [] = "ver=1.1&cmd=query_stat&seq=". Rand (1000,9000). &uin= ". $uin." &tn= ". Rand (1,200)." &un=0 ";

$poststring [] = "ver=1.1&cmd=query_stat&seq=". Rand (1000,9000). &uin= ". $uin." &tn= ". Rand (1,200)." &un=0 ";

$poststring [] = "ver=1.1&cmd=query_stat&seq=". Rand (1000,9000). &uin= ". $uin." &tn=0&un= ". Rand (1,10);

$poststring [] = "ver=1.1&cmd=query_stat&seq=". Rand (1000,9000). &uin= ". $uin." &tn=0&un= ". Rand (1,10);

$poststring [] = "ver=1.1&cmd=query_stat&seq=". Rand (1000,9000). &uin= ". $uin." &tn=0&un= ". Rand (1,10);

$poststring [] = "ver=1.1&cmd=query_stat&seq=". Rand (1000,9000). &uin= ". $uin." &tn=0&un=106814 ";

View friend Information

$poststring [] = "ver=1.1&cmd=getinfo&seq=". Rand (1000,9000). &uin= ". $uin." &lv=0&un=106814 ";

$poststring [] = "ver=1.1&cmd=getinfo&seq=". Rand (1000,9000). &uin= ". $uin." &lv=1&un=106814 ";

$poststring [] = "ver=1.1&cmd=getinfo&seq=". Rand (1000,9000). &uin= ". $uin." &lv=2&un=106814 ";

$poststring [] = "ver=1.1&cmd=getinfo&seq=". Rand (1000,9000). &uin= ". $uin." &lv=3&un=106814 ";

$poststring [] = "ver=1.1&cmd=getinfo&seq=". Rand (1000,9000). &uin= ". $uin." &lv=4&un=106814 ";

$poststring [] = "ver=1.1&cmd=getinfo&seq=". Rand (1000,9000). &uin= ". $uin." &lv=5&un=106814 ";

Add Friends

$poststring [] = "ver=1.1&cmd=addtolist&seq=". Rand (1000,9000). &uin= ". $uin." &un=106814 ";

Send Validation

$poststring [] = "ver=1.1&cmd=ack_addtolist&seq=". Rand (1000,9000). &uin= ". $uin." &un=106814&cd=0&rs=test ";

$poststring [] = "ver=1.1&cmd=ack_addtolist&seq=". Rand (1000,9000). &uin= ". $uin." &un=106814&cd=1&rs=test ";

$poststring [] = "ver=1.1&cmd=ack_addtolist&seq=". Rand (1000,9000). &uin= ". $uin." &un=106814&cd=2&rs=test ";

$poststring [] = "ver=1.1&cmd=ack_addtolist&seq=". Rand (1000,9000). &uin= ". $uin." &un=106814&cd=3&rs=test ";

$poststring [] = "ver=1.1&cmd=ack_addtolist&seq=". Rand (1000,9000). &uin= ". $uin." &un=106814&cd=4&rs=test ";

$poststring [] = "ver=1.1&cmd=ack_addtolist&seq=". Rand (1000,9000). &uin= ". $uin." &un=106814&cd=5&rs=test ";

Delete Friends

$poststring [] = "ver=1.1&cmd=delfromlist&seq=". Rand (1000,9000). &uin= ". $uin." &un=106814 ";

Change state

For ($i =0 $i <=60; $i = $i +5)

{

$poststring [] = "ver=1.1&cmd=change_stat&seq=". Rand (1000,9000). &uin= ". $uin." &st= ". $i;

}

Get the message

$poststring [] = "ver=1.1&cmd=getmsgex&seq=". Rand (1000,9000). &uin= ". $uin." ";

Send a message

$poststring [] = "ver=1.1&cmd=cltmsg&seq=". Rand (1000,9000). &uin= ". $uin." &un=106814&mg=test ";

Log out

$poststring [] = "ver=1.1&cmd=logout&seq=". Rand (1000,9000). &uin= ". $uin." ";

$file = fopen ("P.txt", "w");

foreach ($poststring as $k => $v)

{

Ss_timing_start ();

$fp = Fsockopen ("tqq.tencent.com", "8000", $errno, $errstr, $timeout = 10);

if (! $fp) {

Error Tell us

$content = $k. chr. chr (10). ERROR: $errstr ($errno) ";

}else{

Send the server request

Fputs ($fp, "POST http/1.1");

Fputs ($FP, "Host: $host");

Fputs ($fp, "content-type:application/x-www-form-urlencoded");

Fputs ($FP, "Content-length:". strlen ($v). " ");

Fputs ($fp, "connection:close");

Fputs ($FP, $v. " ");

Loop through the response from the server

$res = "";

while (!feof ($fp)) {

$res. = Fgets ($fp, 4096);

}

Close fp-we are do with it

Fclose ($FP);

$content = $v. chr (CHR). $res;

}

Ss_timing_stop ();

$content. = Chr (CHR). (10). Time: ". Ss_timing_current (). chr (a) Chr (10)." --------------------------------------"Chr. Chr (10);

Fputs ($file, $content);

}

Fclose ($file);

?>

function Ss_timing_start ($name = "Default") {

Global $SS _timing_start_times;

$ss _timing_start_times[$name] = Explode ("", Microtime ());

}

function Ss_timing_stop ($name = "Default") {

Global $SS _timing_stop_times;

$ss _timing_stop_times[$name] = Explode ("", Microtime ());

}

function ss_timing_current ($name = "Default") {

Global $ss _timing_start_times, $ss _timing_stop_times;

if (!isset ($ss _timing_start_times[$name])) {

return 0;

}

if (!isset ($ss _timing_stop_times[$name])) {

$stop _time = Explode ("", Microtime ());

}

else {

$stop _time = $ss _timing_stop_times[$name];

}

$current = $stop _time[1]-$ss _timing_start_times[$name][1];

$current + + $stop _time[0]-$ss _timing_start_times[$name][0];

return $current;

}

?>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.