Connect to windows live messenger xmpp with php

663 views Asked by At

How can i connect xmpp windows live messenger with php? I am using xmpphp and jaxl library and I connected with google talk sucsessfully.

1

There are 1 answers

1
Abhinav Singh On

Jaxl library comes with inbuilt support for PLAIN, google talk X-OAUTH2, DIGEST-MD5, CRAM-MD5, SCRAM-SHA-1, EXTERNAL and facebook X-FACEBOOK-PLATFORM authentication mechanisms.

It does also provide ability to implement any custom authentication mechanism that you might need inside your application. Implementing X-MESSENGER-OAUTH2 authentication should be easy as described below:

Checkout latest version of JAXL library and initialize your JAXL client object as follows:

require_once 'jaxl.php';
$client = new JAXL(array(
    'jid' => 'messenger.live.com', // <-- dummy jid required for DNS SRV lookup
    'pass' => '',
    'log_level' => JAXL_DEBUG
));

Register callback for on_stream_features event as shown below and send auth packet as described in msdn documentation:

$client->add_cb('on_stream_features', function($stanza) {
    global $client, $access_token;
    $auth = new JAXLXml('auth', NS_SASL, array('mechanism'=>'X-MESSENGER-OAUTH2'));
    $auth->t($access_token);
    $client->send($auth);
    return 'wait_for_sasl_response';
});

This should get you going.

Note: Currently version of Jaxl library rely on input jabber id for DNS SRV lookup, from where it extracts target host:port for establishing socket connection. Hence you will have to pass dummy values for jid and pass as shown above (until this gets fixed in future versions).

I have written above steps without any testing, but it should work fine. More details on how to work with JAXLXml style of XML creation can be found here.