$msn = new myMSN ("h058@test.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 (">>>{$data}");
}
}
function Get ()
{
if ($data = @fgets ($this->connect, $this->maxmessage))
{
if ($this->debug)
Print ("<<<{$data}");
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 protocol negotiation
{
$this->put ("VER {$this->trid} MSNP9 CVR0 rn");
$data = $this->get ();
Echo $data;
if (False!== Strripos ($data, "VER"))
$this->envtalk ();
}
function Envtalk ()//environment negotiation
{
$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 ()//Request Confirmation
{
$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); Analysis Server
List ($ip, $port) = Explode (":", $serv); Analyzing IP and Ports
$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:%2f%2fmessenger.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 (); Re-fetch the login server address
Else
$this->getlogincode ($this->sshlogin);
}
}
function relink ($server, $port)//Reset Connection
{
$this->connect = null;
$this->server = $server;
$this->port = $port;
$this->trid = 1;
$this->starttalk ();
}
function Relogintalk ()//re-fetch server address
{
$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); Capture Server Login Match
Print_r ($out);
if (Isset ($out [1]))
{
$this->getlogincode ($out [1]);
}
Else
{
return false;
Exit ("Unable to capture the URL of the login server");
}
}
function Getlogincode ($slogin)//Get Login code
{
Echo ($this->getcode);
if (!is_null ($this->getcode))
{
$ch = Curl_init ("https://". $slogin);
$loginInfo = Array (
"authorization:passport1.4 rgverb=get,orgurl=http%3a%2f%2fmessenger%2emsn%2ecom,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 ("Unable to capture the information of the login Code");
}
}
Else
{
return false;
}
}
function Loginaction ($loginCode)//landing work
{
$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 ());
}
}
?>
http://www.bkjia.com/PHPjc/319718.html www.bkjia.com true http://www.bkjia.com/PHPjc/319718.html techarticle php $msn = new myMSN ("h058@test.com", "123");//MSNv9 class myMSN {private $server = "messenger.hotmail.com"; priva Te $port = 1863; Private $nexus = "https://nexus.passport.com/r ...