PHP 模擬登陸MSN并獲得用戶信息
更新時間:2009年05月16日 00:38:24 作者:
一個可以獲取msn上用戶信息的代碼
復制代碼 代碼如下:
<?php
/*
* PHP100中文網(wǎng),整體提供,測試通過
*/
$msn = new myMSN(php100@php100.com, "123");
// MSNv9
class myMSN {
private $server = "messenger.hotmail.com";
private $port = 1863;
private $nexus = "https://nexus.passport.com/rdr/pprdr.asp";
private $sshLogin = "login.live.com/login2.srf"; //loginnet.passport.com/login2.srf
private $getCode = null;
private $_ip = null;
private $_port = null;
private $connect = null;
private $trID = 1;
private $maxMessage = 4096;
private $userName = null;
private $passWord = null;
private $debug = true;
function myMSN($userName="", $passWord="") {
if (!empty($userName) && !empty($passWord)) {
$this->userName = $userName;
//$this->passWord = urlencode($passWord);
$this->passWord = $passWord;
$this->startTalk();
}
}
function put($data) {
if ($this->isConnect()) {
fputs($this->connect, $data);
$this->trID ;
if ($this->debug)
print("<div style='color:green;font-size:13px;'>>>>{$data}</div>");
}
}
function get() {
if ($data = @fgets($this->connect, $this->maxMessage)) {
if ($this->debug)
print("<div style='color:red;font-size:13px;'><<<{$data}</div>");
return $data;
} else {
return false;
}
}
function isConnect() {
if (!is_null($this->connect))
return true;
else
return false;
}
function close() {
@fclose($this->connect);
}
function startTalk() {
if ($this->connect = fsockopen($this->server, $this->port, $errno, $errstr, 2))
$this->verTalk();
}
function verTalk() // MSN 協(xié)議協(xié)商 {
$this->put("VER {$this->trID} MSNP9 CVR0 rn");
$data = $this->get();
//echo $data;
if (false !== strripos($data, "VER"))
$this->envTalk();
}
function envTalk() // 環(huán)境協(xié)商 {
$this->put("CVR {$this->trID} 0x0409 winnt 5.0 i386 MSNMSGR 7.0.0816 MSMSGS {$this->userName} rn");
$data = $this->get();
//echo $data;
if (false !== strripos($data, "CVR"))
$this->reqTalk();
}
function reqTalk() // 請求確認 {
$this->put("USR {$this->trID} TWN I {$this->userName} rn");
$data = $this->get(); // XFR 3 NS 207.46.107.41:1863 0 65.54.239.210:1863 XFR 3 NS 207.46.107.25:1863 U D
//echo $data;
if (false !== strripos($data, "XFR")) {
list(, , , $serv) = explode(" ", $data); // 分析服務器
list($ip, $port) = explode(":", $serv); // 分析IP和端口
$this->_ip = $ip;
$this->_port = $port;
$this->reLink($ip, $port);
} else {
//echo $data; // USR 3 TWN S ct=1205292058,rver=5.0.3270.0,wp=FS_40SEC_0_COMPACT,lc=1033,id=507,ru=http://messenger.msn.com,tw=0,kpp=1,kv=4,ver=2.1.6000.1,rn=1lgjBfIL,tpf=b0735e3a873dfb5e75054465196398e0
list(, , , , $this->getCode) = explode(" ", trim($data));
//echo $data;
if (empty($this->sshLogin))
$this->reLoginTalk(); // 重新獲取登陸服務器地址
else
$this->getLoginCode($this->sshLogin);
}
}
function reLink($server, $port) // 重置連接 {
$this->connect = null;
$this->server = $server;
$this->port = $port;
$this->trID = 1;
$this->startTalk();
}
function reLoginTalk() // 重新獲取服務器地址 {
$ch = curl_init($this->nexus);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$header = curl_exec($ch);
//print_r($header);
curl_close($ch);
preg_match ('/DALogin=(.*?),/', $header, $out); // 捕捉服務器登陸匹配
//print_r($out);
if (isset($out[1])) {
$this->getLoginCode($out[1]);
}
else {
//return false;
exit("無法捕捉到登陸服務器的URL");
}
}
function getLoginCode($slogin) // 獲取登陸代碼 {
//echo($this->getCode);
if (!is_null($this->getCode)) {
$ch = curl_init("https://" . $slogin);
$loginInfo = array(
"Authorization: Passport1.4 rgVerb=GET,OrgURL=http://messenger.msn.com,sign-in=" . $this->userName . ",pwd=" . $this->passWord . "," . $this->getCode,
"Host: login.passport.com"
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $loginInfo);
//print_r($loginInfo);
//$this->getCode = null;
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$header = curl_exec($ch);
//print_r($header);
preg_match ("/from-PP='(.*?)'/", $header, $out);
//print_r($out);
if (isset($out[1])) {
$this->loginAction($out[1]);
} else {
//return false;
exit("無法捕捉到登陸代碼的信息");
}
} else {
return false;
}
}
function loginAction($loginCode) // 登陸工作 {
$this->put("USR {$this->trID} TWN S {$loginCode} rn"); // USR |trID| SSO S |t=code|
$data = $this->get();
//echo $data;
//print_r($data);
//$this->put("SYN {$this->trID} 0 rn");
//$this->put("CHG {$this->trID} NLN rn");
//print_r($this->get());
}
}
?>
您可能感興趣的文章:
- php實現(xiàn)模擬登陸方正教務系統(tǒng)抓取課表
- PHP函數(shù)分享之curl方式取得數(shù)據(jù)、模擬登陸、POST數(shù)據(jù)
- PHP實現(xiàn)微信模擬登陸并給用戶發(fā)送消息的方法【文字,圖片,圖文】
- php模擬登陸的實現(xiàn)方法分析
- php中通過curl模擬登陸discuz論壇的實現(xiàn)代碼
- php 論壇采集程序 模擬登陸,抓取頁面 實現(xiàn)代碼
- PHP簡單實現(xiàn)模擬登陸功能示例
- php實現(xiàn)微信模擬登陸、獲取用戶列表及群發(fā)消息功能示例
- php通過curl模擬登陸DZ論壇
- PHP模擬登陸163郵箱發(fā)郵件及獲取通訊錄列表的方法
- PHP 模擬登陸功能實例詳解
相關文章
PHP中使用cURL實現(xiàn)Get和Post請求的方法
PHP中使用cURL實現(xiàn)Get和Post請求的方法,需要的朋友可以參考一下2013-03-03PHP中類型轉換 ,常量,系統(tǒng)常量,魔術常量的詳解
這篇文章主要介紹了PHP中類型轉換 ,常量,系統(tǒng)常量,魔術常量的詳解的相關資料,希望通過本文能幫助到大家,讓大家掌握這部分內容,需要的朋友可以參考下2017-10-10PHP中設置時區(qū),記錄日志文件的實現(xiàn)代碼
php中設置時區(qū) 記錄日志文件的實現(xiàn)代碼,需要的朋友可以參考下2013-01-01