Today facebook officially announced availability of it’s chat through jabber/xmpp clients. This is a big win for XMPP, with almost 400 million new probable users adding into XMPP club. In this post, I will demonstrate how to connect to facebook chat servers using Jaxl client library in PHP. It can further be used to make custom chat bots for facebook.
Creating your first facebook chat bot:
Follow the steps to successfully run a facebook chat bot:
- Download Jaxl or checkout latest from trunk
svn checkout http://jaxl.googlecode.com/svn/trunk/ jaxl-read-only
- Edit the configuration file config.ini.php as follows:
// Set an enviornment $env = "prod"; $key = array("prod"=>array("user"=>"facebook_username", "pass"=>"facebook_password", "host"=>"chat.facebook.com", "port"=>5222, "domain"=>"chat.facebook.com" ),
- Run from command line:
abhinavsingh@abhinavsingh-desktop:/jaxl$ sudo php index.php OSType: Linux, Registering shutdown for SIGINT and SIGTERM OpenSSL: Enabled for CLI Attempting DIGEST-MD5 Authentication... Starting Session... Requesting Feature List... Requesting Roster List... Setting Status... Done
Try to send a message to your running chat bot and you shall receive a default message back from the bot saying “Hi, Thanks for your message”.
See further sample codes and explaination on how to build a full fledged gaming chat bots under xmpp category.