This article provides a detailed analysis of the implementation code for PHP to obtain the MSN friend list class. For more information, see
This article provides a detailed analysis of the implementation code for PHP to obtain the MSN friend list class. For more information, see
The Code is as follows:
Error_reporting (7 );
Class msn
{
Private $ startcomm = 0;
Private $ username = '';
Private $ password = '';
Private $ commend = '';
Private $ domain = '';
Private $ socket = '';
Private $ challenge = '';
Private $ status = array ();
Private $ data = array ();
Function set_account ($ username, $ password)
{
$ This-> username = $ username;
$ This-> password = $ password;
}
Function getData (){
$ Buffer = "";
While (! Feof ($ this-> socket )){
$ Buffer. = fread ($ this-> socket, 1024 );
If (preg_match ("// r/", $ buffer )){
Break;
}
}
$ This-> checkData ($ buffer );
}
Function getData2 (){
$ Buffer = "";
While (! Feof ($ this-> socket )){
$ Buffer. = fread ($ this-> socket, 1024 );
If (preg_match ("// r/n/", $ buffer )){
Break;
}
}
$ This-> checkData ($ buffer );
}
Function checkData ($ buffer ){
If (preg_match ("/lc/= (. + ?) /Ui ", $ buffer, $ matches )){
$ This-> challenge = "lc =". $ matches [1];
}
If (preg_match ("/(XFR 3 NS) ([0-9/./:] + ?) (. *) ([0-9/./:] + ?) /Is ", $ buffer, $ matches )){
$ Split = explode (":", $ matches [2]);
$ This-> startcomm = 1;
$ This-> msn_connect ($ split [0], $ split [1]);
}
If (preg_match ("/tpf/= ([a-zA-Z0-9] + ?) /Ui ", $ buffer, $ matches )){
$ This-> nexus_connect ($ matches [1]);
}
$ Split = explode ("/n", $ buffer );
For ($ I = 0; $ I $ Detail = explode ("", $ split [$ I]);
If ($ detail [0] = "LST "){
If (isset ($ detail [2]) $ this-> data [] = array ($ detail [1], urldecode ($ detail [2]);
}
}
$ This-> status = array (200, $ this-> data );
// Echo $ buffer;
}
Function msn_connect ($ server, $ port ){
If ($ this-> socket ){
Fclose ($ this-> socket );
}
$ This-> socket = @ fsockopen ($ server, $ port, $ errno, $ errstr, 20 );
If (! $ This-> socket ){
$ This-> status = array (500, 'msn verification server cannot be connected ');
Return false;
} Else {
$ This-> startcomm ++;
$ This-> send_command ("VER". $ this-> startcomm. "MSNP8 CVR0", 1 );
$ This-> send_command ("CVR". $ this-> startcomm. "0x0409 win 4.10 i386 MSNMSGR 6.2 MSMSGS". $ this-> username, 1 );
$ This-> send_command ("USR". $ this-> startcomm. "twn I". $ this-> username, 1 );
}
}
Function send_command ($ command ){
$ This-> commend = $ command;
$ This-> startcomm ++;
Fwrite ($ this-> socket, $ command. "/r/n ");
$ This-> getData ();
}
Function nexus_connect ($ tpf ){
$ Arr [] = "GET/rdr/pprdr. asp HTTP/1.0/r/n ";
$ Curl = curl_init ();
Curl_setopt ($ curl, CURLOPT_URL, "https://nexus.passport.com: 443/rdr/pprdr. asp ");
Curl_setopt ($ curl, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ curl, CURLOPT_VERBOSE, 0 );
Curl_setopt ($ curl, CURLOPT_HEADER, 1 );
Curl_setopt ($ curl, CURLOPT_HTTPHEADER, $ arr );
Curl_setopt ($ curl, CURLOPT_SSL_VERIFYPEER, FALSE );
$ Data = curl_exec ($ curl );
Curl_close ($ curl );
Preg_match ("/DALogin = (. + ?), /", $ Data, $ matches );
If (! Isset ($ matches [1]) return false;
$ Split = explode ("/", $ matches [1]);
$ Headers [0] = "GET/$ split [1] HTTP/1.1/r/n ";
$ Headers [1] = "Authorization: Passport1.4 OrgVerb = GET, OrgURL = http % 3A % 2F % 2 Fmessenger % 2 Emsn % 2 Ecom, sign-in = ". $ this-> username. ", pwd = ". $ this-> password. ",". trim ($ this-> challenge ). "/r/n ";
$ Curl = curl_init ();
Curl_setopt ($ curl, CURLOPT_URL, "https: //". $ split [0]. ": 443/". $ split [1]);
Curl_setopt ($ curl, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ curl, CURLOPT_VERBOSE, 0 );
Curl_setopt ($ curl, CURLOPT_FOLLOWLOCATION, 1 );
Curl_setopt ($ curl, CURLOPT_HTTPHEADER, $ headers );
Curl_setopt ($ curl, CURLOPT_HEADER, 1 );
Curl_setopt ($ curl, CURLOPT_SSL_VERIFYPEER, FALSE );
$ Data = curl_exec ($ curl );
Curl_close ($ curl );
Preg_match ("/t = (. + ?) '/", $ Data, $ matches );
If (! Isset ($ matches [1]) {
$ This-> status = array (404, 'Your MSN account or password is incorrect ');
Return false;
}
$ This-> send_command ("USR". $ this-> startcomm. "twn s t =". trim ($ matches [1]). "", 2 );
$ This-> send_command ("CHG". $ this-> startcomm. "HDN", 2 );
$ This-> send_command ("SYN". $ this-> startcomm. "0", 2 );
$ This-> getData2 ();
$ This-> send_command ("SYN". $ this-> startcomm. "1 46 2", 2 );
$ This-> getData2 ();
$ This-> send_command ("CHG". $ this-> startcomm. "BSY ");
$ This-> getData ();
}
Public function getStatus ()
{
Return $ this-> status;
}
}
$ Msn = new MSN;
$ Msn-> set_account ('xx @ hotmail.com ', 'xxxxx ');
$ Msn-> msn_connect ("messenger.hotmail.com", 1863 );
$ Data = $ msn-> getStatus ();
Print_r ($ data );
?>
, Hong Kong Space, Hong Kong virtual host, Hong Kong server rent