ING = trim(end($temp_array));
#echo "authenticating";
echo "身份验证中……<br/>";
flush();
$nexus_socket = fsockopen("ssl://nexus.passport.com",443);
fputs($nexus_socket,"GET /rdr/pprdr.asp HTTP/1.0\r\n\r\n");
while ($temp != "\r\n"){
$temp = fgets($nexus_socket,1024);
if (substr($temp,0,12)=="PassportURLs"){
$urls = substr($temp,14);
}
}
$temp_array = explode(",",$urls);
$temp = $temp_array[1];
$temp = substr($temp,8);
$temp_array = explode("/",$temp);
@fclose($nexus_socket);
$ssl_conn = fsockopen("ssl://".$temp_array[0],443);
fputs($ssl_conn,"GET /{$temp_array[1]} HTTP/1.1\r\n");
fputs($ssl_conn,"Authorization: Passport1.4 OrgVerb=GET,OrgURL=http%3A%2F%2Fmessenger%2Emsn%2Ecom,sign-in=".urlencode($username).",pwd=$password,$TOKENSTRING\r\n");
fputs($ssl_conn,"User-Agent: MSMSGS\r\n");
fputs($ssl_conn,"Host: {$temp_array[0]}\r\n");
fputs($ssl_conn,"Connection: Keep-Alive\r\n");
fputs($ssl_conn,"Cache-Control: no-cache\r\n\r\n");
$temp = fgets($ssl_conn,512);
if (rtrim($temp) == "HTTP/1.1 302 Found"){
#echo "redirection";
echo "开始重定向<br/>";
flush();
while ($temp != "\r\n"){
$temp = fgets($ssl_conn,256);
if (substr($temp,0,9)=="Location:"){
$temp_array = explode(":",$temp);
$temp_array = explode("/",trim(end($temp_array)));
break;
}
}
@fclose($ssl_conn);
$ssl_conn = fsockopen("ssl://".$temp_array[2],443);
fputs($ssl_conn,"GET /{$temp_array[3]} HTTP/1.1\r\n");
fputs($ssl_conn,"Authorization: Passport1.4 OrgVerb=GET,OrgURL=http%3A%2F%2Fmessenger%2Emsn%2Ecom,sign-in=".urlencode($username).",pwd=$password,$TOKENSTRING\r\n");
fputs($ssl_conn,"User-Agent: MSMSGS\r\n");
fputs($ssl_conn,"Host: {$temp_array[2]}\r\n");
fputs($ssl_conn,"Connection: Keep-Alive\r\n");
fputs($ssl_conn,"Cache-Control: no-cache\r\n\r\n");
} elseif (rtrim($temp)=="HTTP/1.1 401 Unauthorized"){
#echo "invalidcreds";
echo "验证失败!<br/>";
@fclose($ssl_conn);
die();
} else {
&n |