PHP simulates login to MSN and obtains user information. A code that can obtain user information on msn? Php ** PHP100 Chinese network, the whole is provided, test through * www.PHP100.com * $ msnnewmyMSN (php100@2cto.com, 123); MSNv9classmyM a user information can be obtained on msn code
/*
* BkJia Chinese network, provided as a whole, passed the test
* Www.bkJia.com
*/
$msn = new myMSN(php100@2cto.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); // analyze IP addresses 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://messenger.msn.com, tw = 0, kpp = 1, kv = 4, ver = 2.1.6000.1, rn = 1 lgjBfIL, tpf = b0735e3a873dfb5e75054213196398e0
List (, $ this-> getCode) = explode ("", trim ($ data ));
// Echo $ data;
If (empty ($ this-> sshLogin ))
$ This-> reLoginTalk (); // Obtain the logon server address again.
Else
$ This-> getLoginCode ($ this-> sshLogin );
}
}
Function reLink ($ server, $ port) // reset the connection {
$ This-> connect = null;
$ This-> server = $ server;
$ This-> port = $ port;
$ This-> trID = 1;
$ This-> startTalk ();
}
Function reLoginTalk () // Obtain the server address again {
$ 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 matching
// 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) // Obtain the login code {
// 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 );
Why? Php/** PHP100 Chinese network, the whole is provided, test through * www.PHP100.com */$ msn = new myMSN (php100@2cto.com, 123); // MSNv9 class myM...