|
本帖最后由 Cand 于 2013-2-16 15:30 编辑
- //3gQQ登录,1qq,2密码,3返回sid,4返回验证码地址。
- function qqlogin($qq,$mm,&$returnsid,&$yzmurl){
- $ym=get('http://pt.3g.qq.com/g/s?aid=nLogin');
- $sid=text_midtext($ym,'sid=','&');
- $vdata=text_midtext($ym,'?vdata=','"');
- $submitarr=array(
- 'login_url'=> 'http%3A%2F%2Fpt.3g.qq.com%2Fs%3Faid%3DnLogin',
- 'q_from'=> '',
- 'loginTitle'=> '%E6%89%8B%E6%9C%BA%E8%85%BE%E8%AE%AF%E7%BD%91',
- 'bid'=> '0',
- 'qq'=> $qq,
- 'pwd'=> $mm,
- 'loginType'=> '1',
- 'loginsubmit'=> '%E7%99%BB%E5%BD%95',
- );
- $submiturl='http://pt.3g.qq.com/handleLogin?sid='.$sid.'&vdata='.$vdata;
- $submitdata=http_build_query($submitarr);
- //echo $submitdata;
- global $loginym;
- $loginym=mb_convert_encoding(post($submiturl,$submitdata,''),'GBK','UTF-8');//腾讯的服务器是UTF-8编码。
- $yz=strpos($loginym,'登录成功');
- $yz2=strpos($loginym,'登录密码错误');
- $yz3=strpos($loginym,'输入验证码');
- if($yz!=false){
- $returnsid=text_midtext($loginym,'sid=','&');
- return 1;//登录成功
- }elseif($yz2!=false){
- return 2;//密码错误
- }elseif($yz3!=false){
- $yzmurl=text_midtext($loginym,'<img src="','"');
- return 3;//验证码
- }else{
-
- return $loginym;//都不是的话 就返回源码 看看原因
- }
- }
- //取出中间文本,1全文本,2左边文本,3右边文本
- function text_midtext ($str,$left,$right){
- $a = explode($left,$str);
- $sz2 = $a[1];
- $sz1 = explode($right,$sz2);
- return $sz1[0];
- }
- //post访问网页,1post地址,2post数据,3cookie 服务器需要curl的zhi'c
- function post($str1,$str2,$cookie){
- $ch=curl_init();
- curl_setopt($ch,CURLOPT_URL,$str1);
- curl_setopt($ch,CURLOPT_HEADER,1);
- curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
- curl_setopt($ch,CURLOPT_COOKIEJAR,$cookie);
- curl_setopt($ch,CURLOPT_POST,1);
- curl_setopt($ch,CURLOPT_POSTFIELDS,$str2);
- $data=curl_exec($ch);
- curl_close($ch);
- return $data;
- }
- //get网页访问,返回源码
- function get($url){
- $url = eregi_replace('^http://', '', $url);
- $temp = explode('/', $url);
- $host = array_shift($temp);
- $path = '/'.implode('/', $temp);
- $temp = explode(':', $host);
- $host = $temp[0];
- $port = isset($temp[1]) ? $temp[1] : 80;
- $fp = @fsockopen($host, $port, &$errno, &$errstr, 30);
- if ($fp){
- @fputs($fp, "GET $path HTTP/1.1\r\n");
- @fputs($fp, "Host: $host\r\n");
- @fputs($fp, "Accept: */*\r\n");
- @fputs($fp, "Referer: http://$host/\r\n");
- @fputs($fp, "User-Agent: TTMobile/09.03.18/symbianOS9.1 Series60/3.0 Nokia6120cAP3.03\r\n");
- @fputs($fp, "Connection: Close\r\n\r\n");
- }
- $Content = '';
- while ($str = @fread($fp, 4096))
- $Content .= $str;
- @fclose($fp);
- return $Content;
- }
复制代码 发现这个版块好冷清哦
|
|