<?php
/*
MSN class ver 1.8 by Tommy Wu
License: GPL
You can find MSN protocol from this site: http://msnpiki.msnfanatic.com/index.php/Main_Page
This class support both MSNP15 and MSNP9 for send message. The PHP module needed:
MSNP9: curl pcre
MSNP15: curl pcre mhash mcrypt bcmath
Usually, this class will try to use MSNP15 if your system can support it, if your system can't support it,
it will switch to use MSNP9. But if you use MSNP9, it won't support OIM (Offline Messages).
Sameple Code:
$msn = new MSN;
if (!$msn->connect('YOUR_MSN_ID', 'YOUR_MSN_PASSWORD')) {
echo "Error for connect to MSN network\n";
echo "$msn->error\n";
exit;
}
$msn->sendMessage('Now: '.strftime('%m/%d/%y %H:%M:%S')."\nTesting\nSecond Line\n\n\n\nand Empty Line",
array(
'somebody1@hotmail.com',
'somebody2@hotmail.com'
)
);
echo "Done!\n";
exit;
*/
class MSN
{
var $server = 'messenger.hotmail.com';
var $port = 1863;
var $passport_url = 'https://login.live.com/RST.srf';
var $protocol = 'MSNP15';
var $buildver = '8.1.0178';
var $prod_key = 'PK}_A_0N_K%O?A9S';
var $prod_id = 'PROD0114ES4Z%Q5W';
var $login_method = 'SSO';
var $clientid = '';
var $oim_send_url = 'https://ows.messenger.msn.com/OimWS/oim.asmx';
var $oim_send_soap = 'http://messenger.live.com/ws/2006/09/oim/Store2';
var $oim_maildata_url = 'https://rsi.hotmail.com/rsi/rsi.asmx';
var $oim_maildata_soap = 'http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMetadata';
var $oim_read_url = 'https://rsi.hotmail.com/rsi/rsi.asmx';
var $oim_read_soap = 'http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage';
var $oim_del_url = 'https://rsi.hotmail.com/rsi/rsi.asmx';
var $oim_del_soap = 'http://www.hotmail.msn.com/ws/2004/09/oim/rsi/DeleteMessages';
var $membership_url = 'https://contacts.msn.com/abservice/SharingService.asmx';
var $membership_soap = 'http://www.msn.com/webservices/AddressBook/FindMembership';
var $addmember_url = 'https://contacts.msn.com/abservice/SharingService.asmx';
var $addmember_soap = 'http://www.msn.com/webservices/AddressBook/AddMember';
var $addcontact_url = 'https://contacts.msn.com/abservice/abservice.asmx';
var $addcontact_soap = 'http://www.msn.com/webservices/AddressBook/ABContactAdd';
var $delmember_url = 'https://contacts.msn.com/abservice/SharingService.asmx';
var $delmember_soap = 'http://www.msn.com/webservices/AddressBook/DeleteMember';
var $id;
var $fp = false;
var $error = '';
var $authed = false;
var $user = '';
var $password = '';
var $passport_policy = '';
var $oim_try = 3;
var $oim_ticket = '';
var $contact_ticket = '';
// FIXME: even we login for following site, but... we don't need that now.
var $web_ticket = '';
var $space_ticket = '';
var $storage_ticket = '';
var $debug = false;
var $log_file = '';
var $timeout = 5;
var $stream_timeout = 2;
var $log_path = false;
var $sb;
var $font_fn = 'Arial';
var $font_co = '333333';
var $font_ef = '';
var $windows = false;
var $kill_me = false;
// the message length (include header) is limited (maybe since WLM 8.5 released)
// for WLM: 1664 bytes
// for YIM: 518 bytes
var $max_msn_message_len = 1664;
var $max_yahoo_message_len = 518;
function MSN($protocol = '', $debug = false, $timeout = 15, $client_id = 0x7000800C)
{
if (is_string($debug) && $debug !== '') {
$this->debug = true;
$this->log_file = $debug;
}
else
$this->debug = $debug;
$this->timeout = $timeout;
// check support
if (!function_exists('curl_init')) die("We need curl module!\n");
if (!function_exists('preg_match')) die("We need pcre module!\n");
if ($protocol != 'MSNP9' && $protocol != 'MSNP15')
$protocol = '';
if ($protocol != 'MSNP9' && !function_exists('mhash')) {
if ($protocol == 'MSNP15') die("We need mhash module for $protocol!\n");
$protocol = 'MSNP9';
}
if ($protocol != 'MSNP9' && !function_exists('mcrypt_cbc')) {
if ($protocol == 'MSNP15') die("We need mcrypt module for $protocol!\n");
$protocol = 'MSNP9';
}
if ($protocol != 'MSNP9' && !function_exists('bcmod')) {
if ($protocol == 'MSNP15') die("We need bcmath module for $protocol!\n");
$protocol = 'MSNP9';
}
if ($protocol == 'MSNP9') {
$this->protocol = 'MSNP9';
$this->passport_url = 'https://nexus.passport.com/rdr/pprdr.asp';
$this->buildver = '6.0.0602';
$this->prod_key = 'Q1P7W2E4J9R8U3S5';
$this->prod_id = 'msmsgs@msnmsgr.com';
$this->login_method = 'TWN';
}
else {
$this->protocol = 'MSNP15';
$this->passport_url = 'https://login.live.com/RST.srf';
$this->buildver = '8.1.0178';
$this->prod_key = 'PK}_A_0N_K%O?A9S';
$this->prod_id = 'PROD0114ES4Z%Q5W';
$this->login_method = 'SSO';
$this->oim_send_url = 'https://ows.messenger.msn.com/OimWS/oim.asmx';
$this->oim_send_soap = 'http://messenger.live.com/ws/2006/09/oim/Store2';
/*
http://msnpiki.msnfanatic.com/index.php/Client_ID
Client ID for MSN:
normal MSN 8.1 clientid is:
01110110 01001100 11000000 00101100
= 0x764CC02C
we just use following:
* 0x04: Your client can send/receive Ink (GIF format)
* 0x08: Your client can send/recieve Ink (ISF format)
* 0x8000: This means you support Winks receiving (If not set the official Client will warn with 'contact has an older client and is not capable of receiving Winks')
* 0x70000000: This is the value for MSNC7 (WL Msgr 8.1)
= 0x7000800C;
*/
$this->clientid = $client_id;
}
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
$this->windows = true;
else
$this->windows = false;
return;
}
function get_passport_ticket($url = '')
{
$user = $this->user;
$password = htmlspecialchars($this->password);
if ($url === '')
$passport_url = $this->passport_url;
else
$passport_url = $url;
$XML = '<?xml version="1.0" encoding="UTF-8"?>
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:wsse="http://schemas.xmlsoap.org/ws/2003/06/secext"
xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2002/12/policy"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing"
xmlns:wssc="http://schemas.xmlsoap.org/ws/2004/04/sc"
xmlns:wst="http://schemas.xmlsoap.org/ws/2004/04/trust">
<Header>
<ps:AuthInfo xmlns:ps="http://schemas.microsoft.com/Passport/SoapServices/PPCRL" Id="PPAuthInfo">
<ps:HostingApp>{7108E71A-9926-4FCB-BCC9-9A9D3F32E423}</ps:HostingApp>
<ps:BinaryVersion>4</ps:BinaryVersion>
<ps:UIVersion>1</ps:UIVersion>
<ps:Cookies></ps:Cookies>
<ps:RequestParams>AQAAAAIAAABsYwQAAAAxMDMz</ps:RequestParams>
</ps:AuthInfo>
<wsse:Security>
<wsse:UsernameToken Id="user">
<wsse:Username>'.$user.'</wsse:Username>
<wsse:Password>'.$password.'</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</Header>
<Body>
<ps:RequestMultipleSecurityTokens xmlns:ps="http://s