Facebook chat provides two authentication mechanisms for authenticating chat client users. DIGEST-MD5 require chat client users to enter their username and password, while X-FACEBOOK-PLATFORM can be used to provide better user experience by using simple Facebook Platform authentication. In this blog post, I will demonstrate how to use Jaxl library for X-FACEBOOK-PLATFORM authentication.
Echobot using X-FACEBOOK-PLATFORM
Setup Jaxl library on your system and edit packaged sample echobot application with facebook user account details. Alternately you can also specify connecting user details inside jaxl.ini configuration file.
$jaxl = new JAXL(array(
'user'=>'fbUsername',
'pass'=>'', // Not required, we will use user session key instead
'host'=>'chat.facebook.com',
'domain'=>'chat.facebook.com'
));
Add callback for hook jaxl_get_facebook_key:
JAXLPlugin::add('jaxl_get_facebook_key', array($echobot, 'getFacebookKey'));
Complete getFacebookKey method inside echobot application, which should return back following key information:
function getFacebookKey() {
return array(
'', // Your application secret key
'', // Your application api key
'' // Connecting user session key
);
}
Update doAuth method to use X-FACEBOOK-PLATFORM auth mechanism:
function doAuth($mechanism) {
global $jaxl;
$jaxl->auth("X-FACEBOOK-PLATFORM");
}
Finally, run echobot from command line:
root@ubuntu:/usr/share/php/jaxl/app/echobot# jaxl echobot.php [1942] 2010-08-08 05:35:10 - Socket opened to the jabber host chat.facebook.com:5222 ... [1942] 2010-08-08 05:35:11 - Performing Auth type: X-FACEBOOK-PLATFORM [1942] 2010-08-08 05:35:26 - Auth completed...
Pingback: How to perform X-FACEBOOK-PLATFORM and Google Talk X-OAUTH2 XMPP authentication with PHP Jaxl library | Abhi's Weblog