php自动登录QQ空间,QQ空间自动登录 - brivio的个人页面 - OSCHINA - 中文开源技术交流社区...

这段代码展示了如何使用PHP实现QQ空间的自动登录过程,包括获取login_sig、verifycode、uin以及pt_verifysession_v1等关键信息,并通过HTTP请求完成登录。主要涉及网络请求、正则匹配及密码加密等技术。
摘要由CSDN通过智能技术生成

#自动登录

define('ROOT_PATH',__DIR__);

include_once(ROOT_PATH.'/lib/Http.class.php');

$config=array(

'username'=>'******',

'password'=>'******'

);

//获取login_sig

$url="http://ui.ptlogin2.qq.com/cgi-bin/login";

$data=array(

"hide_title_bar"=>"1",

"low_login"=>"0",

"qlogin_auto_login"=>"0",

"no_verifyimg"=>"1",

"link_target"=>"blank",

"appid"=>"636014201",

"target"=>"self",

"s_url"=>"http://qzone.qq.com",

);

$resp=Http::httpGet($url,$data);

$matches=array();

$pattern="/"

.preg_quote('g_login_sig=encodeURIComponent("')

."(\S+)"

.preg_quote('")')

."/";

preg_match($pattern,$resp['body'],$matches);

$login_sig=$matches[1];

//获取verifycode、pt_verifysession_v1、uin

$url="http://check.ptlogin2.qq.com/check";

$data=array(

'uin'=>$config['username'],

'appid'=>'636014201',

'js_ver'=>'10100',

'js_type'=>'0',

'login_sig'=>'0',

'u1'=>'http://qzone.qq.com',

'r'=>'0.'.time(),

);

$resp=Http::httpGet($url,$data);

$matches=array();

preg_match("/ptui_checkVC\((.+)\)/", $resp['body'],$matches);

$res=explode(',',$matches[1]);

$verifycode=trim(trim($res[1]),"'");

$uin=hex2str(trim(trim($res[2]),"'"));

$pt_verifysession_v1=trim(trim($res[3]),"'");

$url="http://ptlogin2.qq.com/login";

$data=array(

"u"=>$config['username'],

"p"=>getP(),

"verifycode"=>$verifycode,

"aid"=>"636014201",

"u1"=>"http://qzone.qq.com",

"h"=>"1",

"ptredirect"=>"0",

"ptlang"=>"2052",

"from_ui"=>"1",

"dumy"=>"",

"fp"=>"loginerroralert",

"action"=>"1-1-10000",

"mibao_css"=>"",

"t"=>"1",

"g"=>"1",

"js_type"=>"0",

"js_ver"=>"10100",

//跟g_login_sig有关

"login_sig"=>$login_sig,

"pt_uistyle"=>"0",

"pt_vcode_v1"=>"0",

"pt_verifysession_v1"=>$pt_verifysession_v1,

);

$resp=Http::httpGet($url,$data);

// print_r($resp);exit();

//处理密码参数

function getP(){

global $config,$uin,$verifycode;

$j=hex2bin(strtoupper(md5($config['password'])));

$h=strtoupper(md5($j.$uin));

$p=strtoupper(md5($h.strtoupper($verifycode)));

return $p;

}

//转换"\x00\x2f……"成php字符串

function hex2str($hexstr){

$res=explode('\x', $hexstr);

$str="";

foreach($res as $key=>$val){

if(empty($val))continue;

$str.=chr(hexdec($val));

}

return $str;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值