Rumah > pembangunan bahagian belakang > tutorial php > PHP模拟登陆MSN并获得用户信息_PHP教程

PHP模拟登陆MSN并获得用户信息_PHP教程

WBOY
Lepaskan: 2016-07-13 17:37:56
asal
1159 orang telah melayarinya

一个可以获取msn上用户信息的代码

<font face="NSimsun"><?php </font></font>
/*
* bkJia中文网,整体提供,测试通过
* www.bkJia.com
*/<font face="NSimsun"><br> $msn = new myMSN(php100@2cto.com, "123");<br> // MSNv9<br> class myMSN {<br> private $server = "messenger.hotmail.com";<br> private $port = 1863;<br> private $nexus = "https://nexus.passport.com/rdr/pprdr.asp";<br> private $sshLogin = "login.live.com/login2.srf"; //loginnet.passport.com/login2.srf<br> private $getCode = null;<br> private $_ip = null;<br> private $_port = null;<br> private $connect = null;<br> private $trID = 1;<br> private $maxMessage = 4096;<br> private $userName = null;<br> private $passWord = null;<br> private $debug = true;<br> function myMSN($userName="", $passWord="") {<br> if (!empty($userName) && !empty($passWord)) {<br> $this->userName = $userName;<br> //$this->passWord = urlencode($passWord);<br> $this->passWord = $passWord;<br> $this->startTalk();<br> }<br> }<br> function put($data) {<br> if ($this->isConnect()) {<br> fputs($this->connect, $data);<br> $this->trID ;<br> if ($this->debug)<br> print("<div style="color:green;font-size:13px;">>>>{$data}</div>");<br> }<br> }<br> function get() {<br> if ($data = @fgets($this->connect, $this->maxMessage)) {<br> if ($this->debug)<br> print("<div style="color:red;font-size:13px;">");<br> return $data;<br> } else {<br> return false;<br> }<br> }<br> function isConnect() {<br> if (!is_null($this->connect))<br> return true;<br> else<br> return false;<br> }<br> function close() {<br> @fclose($this->connect);<br> }<br> function startTalk() {<br> if ($this->connect = fsockopen($this->server, $this->port, $errno, $errstr, 2))<br> $this->verTalk();<br> }<br> function verTalk() // MSN 协议协商 {<br> $this->put("VER {$this->trID} MSNP9 CVR0 rn");<br> $data = $this->get();<br> //echo $data;<br> if (false !== strripos($data, "VER"))<br> $this->envTalk();<br> }<br> function envTalk() // 环境协商 {<br> $this->put("CVR {$this->trID} 0x0409 winnt 5.0 i386 MSNMSGR 7.0.0816 MSMSGS {$this->userName} rn");<br> $data = $this->get();<br> //echo $data;<br> if (false !== strripos($data, "CVR"))<br> $this->reqTalk();<br> }<br> function reqTalk() // 请求确认 {<br> $this->put("USR {$this->trID} TWN I {$this->userName} rn");<br> $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<br> //echo $data;<br> if (false !== strripos($data, "XFR")) {<br> list(, , , $serv) = explode(" ", $data); // 分析服务器<br> list($ip, $port) = explode(":", $serv); // 分析IP和端口<br> $this->_ip = $ip;<br> $this->_port = $port;<br> $this->reLink($ip, $port);<br> } else {<br> //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<br> list(, , , , $this->getCode) = explode(" ", trim($data));<br> //echo $data;<br> if (empty($this->sshLogin))<br> $this->reLoginTalk(); // 重新获取登陆服务器地址<br> else<br> $this->getLoginCode($this->sshLogin);<br> }<br> }<br> function reLink($server, $port) // 重置连接 {<br> $this->connect = null;<br> $this->server = $server;<br> $this->port = $port;<br> $this->trID = 1;<br> $this->startTalk();<br> }<br> function reLoginTalk() // 重新获取服务器地址 {<br> $ch = curl_init($this->nexus);<br> curl_setopt($ch, CURLOPT_HEADER, 1);<br> curl_setopt($ch, CURLOPT_NOBODY, 1);<br> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);<br> curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);<br> curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);<br> $header = curl_exec($ch);<br> //print_r($header);<br> curl_close($ch);<br> preg_match (/DALogin=(.*?),/, $header, $out); // 捕捉服务器登陆匹配<br> //print_r($out);<br> if (isset($out[1])) {<br> $this->getLoginCode($out[1]);<br> }<br> else {<br> //return false;<br> exit("无法捕捉到登陆服务器的URL");<br> }<br> }<br> function getLoginCode($slogin) // 获取登陆代码 {<br> //echo($this->getCode);<br> if (!is_null($this->getCode)) {<br> $ch = curl_init("https://" . $slogin);<br> $loginInfo = array(<br> "Authorization: Passport1.4 rgVerb=GET,OrgURL=http://messenger.msn.com,sign-in=" . $this->userName . ",pwd=" . $this->passWord . "," . $this->getCode,<br> "Host: login.passport.com"<br> );<br> curl_setopt($ch, CURLOPT_HTTPHEADER, $loginInfo);<br> //print_r($loginInfo);<br> //$this->getCode = null;<br> curl_setopt($ch, CURLOPT_HEADER, 1);<br> curl_setopt($ch, CURLOPT_NOBODY, 1);<br> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);<br> curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);<br> curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); <p align="left"></p> <div style="display:none;"> <span id="url" itemprop="url">http://www.bkjia.com/PHPjc/486535.html</span><span id="indexUrl" itemprop="indexUrl">www.bkjia.com</span><span id="isOriginal" itemprop="isOriginal">true</span><span id="isBasedOnUrl" itemprop="isBasedOnUrl">http://www.bkjia.com/PHPjc/486535.html</span><span id="genre" itemprop="genre">TechArticle</span><span id="description" itemprop="description">一个可以获取msn上用户信息的代码 ?php /* * PHP100中文网,整体提供,测试通过 * www.PHP100.com */ $msn = new myMSN(php100@2cto.com, 123); // MSNv9 class myM...</span> </div> </div> <div class="art_confoot"></div> </font>

sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan