MSNPAuth: Authenticating in PHP

MSNPAuth is a PHP class used for authentication when connecting to .NET Messenger Service, you simply pass it the Passport address, the password and the challenge string received in the USR command and it connects to the Passport authentication system to fetch authentication key.

Usage:

$msnpauth = new MSNPAuth($passport, $password, $params[4]);
$hash = $msnpauth->getKey();

$passport would be the e-mail address that is being signed in
$password would be the password for that account
$params[4] would be the string sent in the USR command from the notification server,

With the last argument, the notification server communication goes like this:

[SEND] USR 6 TWN I bob@hotmail.com\r\n
[RECV] USR 6 TWN S lc=1033,id=507,tw=40,fs=1,ru=http%3A%2F%2Fmessenger%2Emsn%2Ecom,ct=1128154104,kpp=1,kv=7,ver=2.1.6000.1,rn=C6D!I5Ic,tpf=41a9cb6f69e60faa44c8570126f045ed\r\n

You use 4th argument (starting from 0) from the response (ie. lc=1033,id=507,tw=40…)
Make sure you are actually sending the right string, if you were to split the response into an array, it should look like this:

Array
(
    [0] => USR
    [1] => 2
    [2] => TWN
    [3] => S
    [4] => lc=1033,id=507,tw=40,fs=1,ru=http%3A%2F%2Fmessenger%2Emsn%2Ecom,ct=1128154104,kpp=1,kv=7,ver=2.1.6000.1,rn=C6D!I5Ic,tpf=41a9cb6f69e60faa44c8570126f045ed
)

Originally when I had to upgrade all my MSN PHP scripts to use MSNP8 in 2003, I tried using fsockopen with SSL. The only problem was, the Web host was using PHP 4.2 and this functionality was introduced in PHP 4.3. Instead, I had to use cURL.

There is now also an alternate version which does use fsockopen, this is now labelled version 1.2, the cURL one will remain version 1.1.

MSNPAuth automatically chooses the right server to authenticate with, skipping nexus and the login.passport.com if applicable, making it a bit faster.

msnpauth.php, v1.1.3 (cURL)
msnpauth.php, v1.2.1 (fsockopen)

6 Responses to “MSNPAuth: Authenticating in PHP”


  1. 1 kory

    i want to know the follow steps to keep it working plz i wait

  2. 2 peeze

    i’ tried to use the one that uses fsockopen, but i did not work (Warning: fsockopen(): no SSL support in this build in \includes\MSNPAuth.class.php on line 67). How can I fix that?

  3. 3 Andre

    Link it’s not working!!!

  4. 4 Daniel

    Fixed it now, sorry!

  5. 5 Onur Cobanli

    Hi, I have read that cURL function is faster that fsockopen, but your latest module seems to use fsockopen directly, will you write a new module or shall we keep with the older version (1.1.2)?

  6. 6 David Hermansson

    Can’t get this to work. Could you publish the version in the sandbox? Cuz that version is still working. Don’t know exactly what’s not working, but I know that it’s not working ;)

  1. 1 Fanatic Live » Blog Archive » Send a message using PHP
  2. 2 Troubleshooting phpListGrab » Fanatic Live
  3. 3 Send a message using PHP at Fanatic Live
  4. 4 PHP bots using sockets at Fanatic Live
  5. 5 sendMsg: Sending messages using PHP | ????
  6. 6 ??php?????msn?? | ???

Leave a Reply