QQ的HTTP接口PHP探究
=4&RS=TEST";
$poststring[] = "VER=1.1&CMD=Ack_AddToList&SEQ=".rand(1000,9000)."&UIN=".$uin."&UN=106814&CD=5&RS=TEST"; //删除好友 $poststring[] = "VER=1.1&CMD=DelFromList&SEQ=".rand(1000,9000)."&UIN=".$uin."&UN=106814"; //改变状态 for($i=0;$i<=60;$i=$i+5) { $poststring[] = "VER=1.1&CMD=Change_Stat&SEQ=".rand(1000,9000)."&UIN=".$uin."&ST=".$i; } //获得消息 $poststring[] = "VER=1.1&CMD=GetMsgEx&SEQ=".rand(1000,9000)."&UIN=".$uin.""; //发送消息 $poststring[] = "VER=1.1&CMD=CLTMSG&SEQ=".rand(1000,9000)."&UIN=".$uin."&UN=106814&MG=TEST"; //登出 $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(13).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 done with it fclose($fp); $content = $v.chr(13).chr(10).$res; } ss_timing_stop(); $content .= chr(13).chr(10)."Time: ".ss_timing_current().chr(13).chr(10)."--------------------------------------".chr(13).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; } ?> |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |