Home  >  Article  >  Backend Development  >  PHP实现QQ登录实例代码_php实例

PHP实现QQ登录实例代码_php实例

WBOY
WBOYOriginal
2016-06-07 17:09:44661browse

分享一段利用PHP实现QQ登陆的代码,原理是用curl模拟发送post登录,cookie保存本地,实现真正的3GQQ登陆。这里代码理论可以支持永久单挂QQ—真正做到免费挂qq哦。

<?php
function qqlogin(){
$qqno='这里填写QQ账号';
$qqpw='这里填写QQ密码';
$cookie = dirname(__FILE__).'/cookie.txt';
$post = array( 
'login_url' => 'http://pt.3g.qq.com/s?sid=ATAll43N7ZULRQ5V8zdfojol&aid=nLogin',
'q_from' => '', 
'loginTitle' => 'login', 
'bid' => '0', 
'qq' => $qqno, 
'pwd' => $qqpw, 
'loginType' => '1', 
'loginsubmit' => 'login',
);
$url = 'http://pt.3g.qq.com/handleLogin?aid=nLoginHandle&sid=ATAll43N7ZULRQ5V8zdfojol';//请求url
$curl = curl_init();
curl_setopt($curl, CURLOPT_HEADER, 0); 
curl_setopt($curl, CURLOPT_URL,$url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_COOKIEJAR, $cookie);
// ?Cookie
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post));
$result = curl_exec($curl);
curl_close($curl);
}
?>
qqlogin();

如何查看是否登陆成功:

运行过此段代码以后,你的QQ将被挤掉,弹出以下提示,这时候你可以登陆你的其它QQ号码查看你测试号码的登陆状态。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn