Jeg har selv forsøgt mig lidt frem her:
<?php
$host = 'messenger.hotmail.com';
$path = '/';
$port = '1863';
class MSN{
private $buffer = '';
private $socket;
private $socketSSL;
private $username;
private $password;
private $number = 0;
private $host = 'messenger.hotmail.com';
private $port = 1863;
private $path = '/rdr/pprdr.asp';
private $auth;
public function __construct($username,$password)
{
$this->username = $username;
$this->password = $password;
$this->connect();
$this->communicate(1);
$this->connect();
$this->communicate(2);
$this->connect(true);
$this->nexus();
$this->connect(true);
$this->login();
$this->communicate(3);
}
private function connect($ssl=false)
{
if($ssl)
{
if(isset($this->socketSSL))
{
fclose($this->socketSSL);
}
$this->socketSSL = fsockopen('
ssl://' . $this->host, $this->port, $errno, $errstr, 30);
if (!$this->socket)
{
return false;
}
}
else
{
if(isset($this->socket))
{
fclose($this->socket);
}
$this->socket = fsockopen('
tcp://' . $this->host, $this->port, $errno, $errstr, 30);
if (!$this->socket)
{
return false;
}
}
}
private function communicate($sequence)
{
switch($sequence)
{
case 1:
case 2:
$this->send('VER '.++$this->number.' MSNP8 CVR0');
$this->send('CVR '.++$this->number.' 0x0409 win 4.10 i386 MSNMSGR 5.0.0544 MSMSGS '.$this->username.'@hotmail.com');
$this->send('USR '.++$this->number.' TWN I '.$this->username.'@hotmail.com');
break;
case 3:
$this->send('USR '.++$this->number.' TWN S t='.$this->auth);
break;
}
}
private function send($command,$ssl=false)
{
echo $command . "\r\n";
if($ssl)
{
fwrite($this->socketSSL,$command . "\r\n");
}
else
{
fwrite($this->socket,$command . "\r\n");
}
$this->recv($ssl);
}
private function recv($ssl=false)
{
$this->buffer='';
if($ssl)
{
while(!feof($this->socketSSL))
{
$this->buffer .= fread($this->socketSSL,4096);
if(preg_match("/\r\n/",$this->buffer))
{
break;
}
}
}
else
{
while(!feof($this->socket))
{
$this->buffer .= fread($this->socket,4096);
if(preg_match("/\r\n/",$this->buffer))
{
break;
}
}
echo $this->buffer;
flush();
}
$this->parse();
}
private function parse()
{
switch($this->number)
{
case 3:
if(preg_match('/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}/', $this->buffer, $match))
{
$this->host = $match[0];
}
break;
case 6:
if(preg_match('%DALogin=(.+?)/(.+?),%', $this->buffer, $match))
{
$this->host = $match[1];
$this->path = $match[2];
$this->port = 443;
}
elseif(preg_match('/tpf=(.+?)\\r\\n/', $this->buffer, $match))
{
$this->host = 'nexus.passport.com';
$this->port = 443;
$this->auth = $match[1];
}
elseif(preg_match('/\\\'t=(.+)\\\'/', $this->buffer, $match))
{
$this->auth = $match[1];
}
break;
}
}
private function nexus()
{
$this->send('GET '.$this->path.' HTTP/1.0'."\r\n",true);
}
private function login()
{
$this->send('GET /'.$this->path.' HTTP/1.1'."\r\n".'Authorization: Passport1.4 OrgVerb=GET,OrgURL=http%3A%2F%2Fmessenger%2Emsn%2Ecom,sign-in='.$this->username.'%40hotmail.com,pwd='.$this->password.',lc=1033,id=507,tw=40,fs=1,ru=http%3A%2F%2Fmessenger%2Emsn%2Ecom,ct=1062764229,kpp=1,kv=5,ver=2.1.0173.1,tpf='.$this->auth."\r\n".'Host: '.$this->host."\r\n",true);
}
}
echo '<pre>';
$myMSN = new MSN('BRUGERNAVN','KODEORD');
echo '</pre>';
/*
http://www.hypothetic.org/docs/msn/notification/authentication-example.phphttp://www.hypothetic.org/docs/msn/notification/example_session.php*/
?>