一个可以获取msn上用户信息的代码
<font face="NSimsun"><?php</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;><<<{$data}</div>");<br>
$data を返します;<br>
} その他 {<br>
false を返します;<br>
}<br>
}<br>
関数 isConnect() {<br>
if (!is_null($this->connect))<br>
true を返します;<br>
それ以外<br>
false を返します;<br>
}<br>
関数 close() {<br>
@fclose($this->connect);<br>
}<br>
関数 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>
// $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>
// $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>
// $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>
} その他 {<br>
// $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>
// $data をエコー;<br>
if (空($this->sshLogin))<br>
$this->reLoginTalk(); // 重新获取登陆服务器地址<br>
それ以外<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>
他に{<br>
// 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>
「認証: Passport1.4 rgVerb=GET,OrgURL=http://messenger.msn.com,sign-in=」。 $this->userName 。 ",pwd=" 。 $this->passWord 。 「、」。 $this->getCode,<br>
「ホスト: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);</font>