Php: reading user information on msn _ PHP Tutorial

Source: Internet
Author: User
Php reads user information on msn .? Php $ msnnewmyMSN (h058@test.com, 123); MSNv9classmyMSN {private $ servermessenger.hotmail.com; private $ port1863; private $ nexusnexus. passport. comr $ 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); // 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: % 2F % 2Fmessenger.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) // Get 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 % 3A % 2F % 2 Fmessenger % 2 Emsn % 2 Ecom, 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 login code information ");
}
}
Else
{
Return false;
}
}
Function loginAction ($ loginCode) // login
{
$ 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.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/319718.htmlTechArticle? Php $ msn = new myMSN ("h058@test.com", "123"); // MSNv9 class myMSN {private $ server = "messenger.hotmail.com"; private $ port = 1863; private $ nexus = "https://nexus.passport.com/r...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.