<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Abhi&#039;s Weblog &#187; XMPP</title>
	<atom:link href="http://abhinavsingh.com/blog/tag/xmpp/feed/" rel="self" type="application/rss+xml" />
	<link>http://abhinavsingh.com/blog</link>
	<description>PHP, Memcached, XMPP and Web Development</description>
	<lastBuildDate>Wed, 06 Apr 2011 22:19:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>JAXL library &#8211; List of available hooks for various XMPP events</title>
		<link>http://abhinavsingh.com/blog/2011/04/jaxl-library-list-of-available-hooks-for-various-xmpp-events/</link>
		<comments>http://abhinavsingh.com/blog/2011/04/jaxl-library-list-of-available-hooks-for-various-xmpp-events/#comments</comments>
		<pubDate>Wed, 06 Apr 2011 22:16:57 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[XMPP]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[JAXL]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=680</guid>
		<description><![CDATA[Jaxl 2.x provides an event mechanism using which developers can register callbacks for various xmpp events inside their application code. This blog post will demonstrate how to register callbacks for required xmpp events and go through a list of all available hooks. Finally, we will discuss parameters that are passed to called back methods by [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2011%2F04%2Fjaxl-library-list-of-available-hooks-for-various-xmpp-events%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2011%2F04%2Fjaxl-library-list-of-available-hooks-for-various-xmpp-events%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=Documentation,JAXL,XMPP&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Jaxl 2.x provides an event mechanism using which developers can register callbacks for various xmpp events inside their application code. This blog post will demonstrate how to register callbacks for required xmpp events and go through a list of all available hooks. Finally, we will discuss parameters that are passed to called back methods by Jaxl core.</p>
<p><strong style="font-size:18px;"><u>Registering callback on XMPP events</u></strong><br />
Applications can register callback for various XMPP events. Jaxl core will then callback application methods (with 2 parameters) every time associated XMPP event occurs. Shown below are some sample examples for registering callbacks.</p>
<p>When application callback&#8217;d method is a function:</p>
<pre class="php" name="code">
function postAuth($payload, $jaxl) {

}
$jaxl->addPlugin('jaxl_post_auth', 'postAuth');
</pre>
<p>When application callback&#8217;d method is a public static method of a class:</p>
<pre class="php" name="code">
class MyXMPPApp {
    public static function postAuth($payload, $jaxl) {

    }
}
$jaxl->addPlugin('jaxl_post_auth', array('MyXMPPApp', 'postAuth'));
</pre>
<p>When application callback&#8217;d method is a public method inside a class:</p>
<pre class="php" name="code">
class MyXMPPApp {
    function postAuth($payload, $jaxl) {

    }
}
$MyXMPPApp = new MyXMPPApp();
$jaxl->addPlugin('jaxl_post_auth', array($MyXMPPApp, 'postAuth'));
</pre>
<p>In all the above examples <code>jaxl_post_auth</code> is one of the available hook for registering callbacks.</p>
<p><strong style="font-size:18px;"><u>List of available hooks</u></strong><br />
Below is a complete list of available hooks in order of their occurrence within a Jaxl instance life cycle:</p>
<p>Hooks for events related to instance connection and authentication steps in various modes:</p>
<ul>
<li>jaxl_post_connect</li>
<li>jaxl_get_auth_mech</li>
<li>jaxl_get_facebook_key</li>
<li>jaxl_post_auth_failure</li>
<li>jaxl_post_auth</li>
<li>jaxl_post_handshake</li>
<li>jaxl_pre_shutdown</li>
<li>jaxl_post_disconnect</li>
<li>jaxl_get_empty_body</li>
</ul>
<p>Hooks for events related to XMPP stream and stanza&#8217;s:</p>
<ul>
<li>jaxl_get_stream_error</li>
<li>jaxl_get_presence</li>
<li>jaxl_get_message</li>
<li>jaxl_get_iq_get</li>
<li>jaxl_get_iq_set</li>
<li>jaxl_get_iq_error</li>
<li>jaxl_send_message</li>
<li>jaxl_send_presence</li>
</ul>
<p>Hooks for events related to reading/writing of XMPP packets and internal packet routing:</p>
<ul>
<li>jaxl_get_xml</li>
<li>jaxl_send_xml</li>
<li>jaxl_send_body</li>
<li>jaxl_pre_handler</li>
<li>jaxl_post_handler</li>
</ul>
<p><strong>TO-DO:</strong> Update when every hook is called inside your application life cycle and list of parameters passed for each callback. As of now you can <code>var_dump($payload);</code> inside your callback method.</p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2011%2F04%2Fjaxl-library-list-of-available-hooks-for-various-xmpp-events%2F"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDExLzA0L2pheGwtbGlicmFyeS1saXN0LW9mLWF2YWlsYWJsZS1ob29rcy1mb3ItdmFyaW91cy14bXBwLWV2ZW50cy88d3B0Yj5KQVhMIGxpYnJhcnkgJiM4MjExOyBMaXN0IG9mIGF2YWlsYWJsZSBob29rcyBmb3IgdmFyaW91cyBYTVBQIGV2ZW50czx3cHRiPmh0dHA6Ly9hYmhpbmF2c2luZ2guY29tL2Jsb2c8d3B0Yj5BYmhpJiMwMzk7cyBXZWJsb2c%3D";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2010/08/php-code-setup-and-demo-of-jaxl-boshchat-application/" title="PHP Code, Setup and Demo of Jaxl boshchat application">PHP Code, Setup and Demo of Jaxl boshchat application</a> (80)</li><li><a href="http://abhinavsingh.com/blog/2010/08/how-to-write-external-jabber-components-in-php-using-jaxl-library/" title="How to write External Jabber Components in PHP using Jaxl library?">How to write External Jabber Components in PHP using Jaxl library?</a> (15)</li><li><a href="http://abhinavsingh.com/blog/2010/08/xep-0045-%e2%80%93-multi-user-chat-muc-available-methods-in-jaxl-2-0/" title="XEP 0045 – Multi User Chat (MUC) available methods in Jaxl 2.0">XEP 0045 – Multi User Chat (MUC) available methods in Jaxl 2.0</a> (19)</li><li><a href="http://abhinavsingh.com/blog/2010/08/facebook-chat-connect-with-x-facebook-platform-using-jaxl-2-0/" title="Facebook chat connect with X-FACEBOOK-PLATFORM using Jaxl 2.0">Facebook chat connect with X-FACEBOOK-PLATFORM using Jaxl 2.0</a> (112)</li><li><a href="http://abhinavsingh.com/blog/2010/08/xep-0133-service-administration-available-methods-in-jaxl-2-0/" title="XEP 0133 &#8211; Service Administration available methods in Jaxl 2.0">XEP 0133 &#8211; Service Administration available methods in Jaxl 2.0</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2011/04/jaxl-library-list-of-available-hooks-for-various-xmpp-events/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PHP Code, Setup and Demo of Jaxl boshchat application</title>
		<link>http://abhinavsingh.com/blog/2010/08/php-code-setup-and-demo-of-jaxl-boshchat-application/</link>
		<comments>http://abhinavsingh.com/blog/2010/08/php-code-setup-and-demo-of-jaxl-boshchat-application/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 10:13:42 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[XMPP]]></category>
		<category><![CDATA[Bosh]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[JAXL]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=676</guid>
		<description><![CDATA[Jaxl 2.0 bosh support allow web developers to write real time web applications within minutes, without having any pre-requisite knowledge about the XMPP protocol itself. In this blog post, I will walk you through setup and demo of an XMPP based web chat application using Jaxl library. Get the code Follow the following steps to [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F08%2Fphp-code-setup-and-demo-of-jaxl-boshchat-application%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F08%2Fphp-code-setup-and-demo-of-jaxl-boshchat-application%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=Bosh,Documentation,JAXL,PHP,XMPP&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Jaxl 2.0 bosh support allow web developers to write real time web applications within minutes, without having any pre-requisite knowledge about the XMPP protocol itself. In this blog post, I will walk you through setup and demo of an XMPP based web chat application using Jaxl library.</p>
<p><strong style="font-size:18px;"><u>Get the code</u></strong><br />
Follow the following steps to download and install this sample web application on your systems:</p>
<ul>
<li>Clone the development branch of Jaxl library
<pre class="php" name="code">root@ubuntu:~/git# git clone git@github.com:abhinavsingh/JAXL.git
root@ubuntu:~/git# cd JAXL/
root@ubuntu:~/git/JAXL#</pre>
<p> If you are not familiar with git, simply visit <a href="http://github.com/abhinavsingh/JAXL">JAXL@github</a>, click <strong>Download Source</strong> and extract under <code>~/git/JAXL</code> directory on your system</li>
<li>Once inside Jaxl source directory, build the latest development package
<pre class="php" name="code">root@ubuntu:~/git/JAXL# ./build.sh
building...</pre>
</li>
<li>Install Jaxl library (<a href="http://abhinavsingh.com/blog/2010/08/jaxl-2-0-installation-usage-guide-and-example-apps/">view installation detail and options</a>)
<pre class="php" name="code">root@ubuntu:~/git/JAXL# ./build.sh install
uninstalling old package...
installing...</pre>
</li>
</ul>
<p><strong style="font-size:18px;"><u>Setup web chat application</u></strong><br />
Jaxl library is default installed under <code>/usr/share/php/jaxl</code> folder. Application code for our web chat application can be found under <code>/usr/share/php/jaxl/app/boshchat</code> folder.</p>
<p>Follow these steps to setup web chat application on your system:</p>
<ul>
<li>I assume you have <code>http://localhost/</code> configured on your local web server and it runs out of <code>/var/www</code> folder. Create following symlinks:
<pre class="php" name="code">root@ubuntu:~/git/JAXL# cd /var/www
root@ubuntu:/var/www# ln -s /usr/share/php/jaxl/app/boshchat/boshchat.php index.php
root@ubuntu:/var/www# ln -s /usr/share/php/jaxl/app/boshchat/jaxl.ini jaxl.ini
root@ubuntu:/var/www# ln -s /usr/share/php/jaxl/env/jaxl.js jaxl.js
root@ubuntu:/var/www# ln -s /usr/bin/jaxl jaxl.php</pre>
<p> Edit/Remove <strong>#!/usr/bin/env php</strong> inside <code>jaxl.php</code> if it causes any problem on your system.</li>
<li>Open and edit jaxl.ini
<pre class="php" name="code">define('JAXL_BOSH_COOKIE_DOMAIN', false);</pre>
</li>
<li>I assume you have access to XMPP over Bosh enabled jabber server. Ejabberd users can verify this by hitting <code>http://localhost:5280/http-bind</code> in the browser</li>
<li>Open and edit index.php
<pre class="php" name="code">define('BOSHCHAT_ADMIN_JID', 'admin@localhost');</pre>
<p> All messages sent using this web chat application will be routed to <code>BOSHCHAT_ADMIN_JID</code></li>
</ul>
<p><strong style="font-size:18px;"><u>Ready for the demo</u></strong><br />
To run this example web chat application, visit <code>http://localhost</code> in your browser window. Enter a username/password already registered on your jabber server and press connect.</p>
<p>Login as <code>BOSHCHAT_ADMIN_JID</code> using a desktop client, so that you can receive messages sent from the browser on your desktop client.</p>
<p>Below is a screenshot when I logged in as &#8220;abhinavsingh&#8221; from browser and <code>BOSHCHAT_ADMIN_JID</code> was set to &#8220;jaxl@jaxl.im&#8221;:</p>
<p><a href="http://abhinavsingh.com/blog/wp-content/uploads/2010/08/jaxl-bosh-chat-screenshot.jpg" style="margin-top:20px;"><img style="margin-top:10px;" src="http://abhinavsingh.com/blog/wp-content/uploads/2010/08/jaxl-bosh-chat-screenshot.jpg" alt="" title="jaxl-bosh-chat-screenshot" width="710" height="430" class="aligncenter size-full wp-image-954" /></a></p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F08%2Fphp-code-setup-and-demo-of-jaxl-boshchat-application%2F","http:\/\/github.com\/abhinavsingh\/JAXL"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDEwLzA4L3BocC1jb2RlLXNldHVwLWFuZC1kZW1vLW9mLWpheGwtYm9zaGNoYXQtYXBwbGljYXRpb24vPHdwdGI%2BUEhQIENvZGUsIFNldHVwIGFuZCBEZW1vIG9mIEpheGwgYm9zaGNoYXQgYXBwbGljYXRpb248d3B0Yj5odHRwOi8vYWJoaW5hdnNpbmdoLmNvbS9ibG9nPHdwdGI%2BQWJoaSYjMDM5O3MgV2VibG9n";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2011/04/jaxl-library-list-of-available-hooks-for-various-xmpp-events/" title="JAXL library &#8211; List of available hooks for various XMPP events">JAXL library &#8211; List of available hooks for various XMPP events</a> (3)</li><li><a href="http://abhinavsingh.com/blog/2010/08/releasing-jaxl-2-0-object-oriented-xmpp-framework-in-php/" title="Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP">Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP</a> (6)</li><li><a href="http://abhinavsingh.com/blog/2010/01/jaxl-bosh-demo-im-chat-client-for-all-wordpress-blogs/" title="JAXL BOSH Demo: IM chat client for all Wordpress blogs">JAXL BOSH Demo: IM chat client for all Wordpress blogs</a> (35)</li><li><a href="http://abhinavsingh.com/blog/2010/01/get-real-time-system-server-load-notification-on-any-im-using-php-and-xmpp/" title="Get real time system &amp; server load notification on any IM using PHP and XMPP">Get real time system &amp; server load notification on any IM using PHP and XMPP</a> (20)</li><li><a href="http://abhinavsingh.com/blog/2010/01/get-lyrics-for-any-song-using-xmpp-and-php-right-into-your-im-add-lyricsflygtalkbots-com/" title="Get lyrics for any song using XMPP and PHP right into your IM &#8211; Add lyricsfly@gtalkbots.com">Get lyrics for any song using XMPP and PHP right into your IM &#8211; Add lyricsfly@gtalkbots.com</a> (17)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2010/08/php-code-setup-and-demo-of-jaxl-boshchat-application/feed/</wfw:commentRss>
		<slash:comments>80</slash:comments>
		</item>
		<item>
		<title>Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP</title>
		<link>http://abhinavsingh.com/blog/2010/08/releasing-jaxl-2-0-object-oriented-xmpp-framework-in-php/</link>
		<comments>http://abhinavsingh.com/blog/2010/08/releasing-jaxl-2-0-object-oriented-xmpp-framework-in-php/#comments</comments>
		<pubDate>Mon, 02 Aug 2010 22:41:07 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[Open Source Projects]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[XMPP]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[JAXL]]></category>
		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=641</guid>
		<description><![CDATA[After months of restructuring the Jaxl library, I am pleased to announce Jaxl 2.0, an object oriented XMPP framework in PHP for developing real time applications for browsers, desktops and hand held devices. What&#8217;s new in Jaxl 2.0? A lot of structural changes has been done from the previous version to make it more scalable, [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F08%2Freleasing-jaxl-2-0-object-oriented-xmpp-framework-in-php%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F08%2Freleasing-jaxl-2-0-object-oriented-xmpp-framework-in-php%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=Framework,JAXL,Open+Source,PHP,XMPP&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>After months of restructuring the Jaxl library, I am pleased to announce Jaxl 2.0, an object oriented XMPP framework in PHP for developing real time applications for browsers, desktops and hand held devices.</p>
<p><strong style="font-size:18px;"><u>What&#8217;s new in Jaxl 2.0?</u></strong></p>
<ul>
<li>A lot of structural changes has been done from the previous version to make it more scalable, robust, flexible and easy to use</li>
<li>Library now provides an event mechanism, allowing developers to register callbacks for various xmpp events in their application code</li>
<li>Use integrated BOSH support to write real time web applications in minutes</li>
<li>More than 10 new implemented XMPP extensions (XEP&#8217;s) added</li>
<li>Development hosting moves to <a href="http://github.com/abhinavsingh/JAXL">github</a>, stable releases available at <a href="http://code.google.com/p/jaxl/">google code</a></li>
</ul>
<p><strong style="font-size:18px;"><u>Documentation for Jaxl users</u></strong><br />
Below is a list of getting started documentation for XMPP app developers:</p>
<ul>
<li><a href="http://abhinavsingh.com/blog/2010/08/jaxl-2-0-installation-usage-guide-and-example-apps">Installation, Usage guide and Sample applications</a></li>
<li><a href="http://abhinavsingh.com/blog/2010/08/jaxl-2-0-core-classes-available-methods-and-directory-structure/">Jaxl Core classes, available methods and directory structure</a></li>
<li><a href="http://abhinavsingh.com/blog/2010/08/writing-a-command-line-xmpp-bot-echobot-using-jaxl-2-0/">Writing your first command line bot using Jaxl</a></li>
<li><a href="http://abhinavsingh.com/blog/2010/08/facebook-chat-connect-with-x-facebook-platform-using-jaxl-2-0/">Facebook chat connect with X-FACEBOOK-PLATFORM using Jaxl</a></li>
<li><a href="http://abhinavsingh.com/blog/2010/08/php-code-setup-and-demo-of-jaxl-boshchat-application/">Code, Setup and Demo of Bosh chat application</a></li>
<li><a href="http://abhinavsingh.com/blog/2010/08/how-to-write-external-jabber-components-in-php-using-jaxl-library/">Writing External Jabber Components in PHP using Jaxl library</a></li>
<li>Writing XMPP web applications using Jaxl in 5 minutes <em>(coming soon)</em></li>
<li>Available hooks for various xmpp events <em>(coming soon)</em></li>
<li>Migration guide for Jaxl 1.x users <em>(coming soon)</em></li>
</ul>
<p><strong style="font-size:18px;"><u>Implemented XEP&#8217;s</u></strong><br />
A lot of new XEP&#8217;s has been implemented and packaged with Jaxl 2.0. Developers can use Jaxl event mechanism to implement new XEP&#8217;s without knowing the working of other core parts of the library.</p>
<p>Below is a list of released implemented XEP with Jaxl 2.0:</p>
<ul>
<li>0004 &#8211; Data Forms</li>
<li>0030 &#8211; Service Discovery</li>
<li><a href="http://abhinavsingh.com/blog/2010/08/xep-0045-%e2%80%93-multi-user-chat-muc-available-methods-in-jaxl-2-0/">0045 &#8211; Multi-User Chat</a></li>
<li>0050 &#8211; Ad-Hoc Commands</li>
<li>0085 &#8211; Chat State Notification</li>
<li>0092 &#8211; Software Version</li>
<li><a href="http://abhinavsingh.com/blog/2010/08/how-to-write-external-jabber-components-in-php-using-jaxl-library/">0114 &#8211; Jabber Component Protocol</a></li>
<li>0115 &#8211; Entity Capabilities</li>
<li>0124 &#8211; Bosh Implementation</li>
<li><a href="http://abhinavsingh.com/blog/2010/08/xep-0133-service-administration-available-methods-in-jaxl-2-0/">0133 &#8211; Service Administration</a></li>
<li>0119 &#8211; XMPP Ping</li>
<li>0202 &#8211; Entity Time</li>
<li><a href="http://abhinavsingh.com/blog/2010/08/php-code-setup-and-demo-of-jaxl-boshchat-application/">0206 &#8211; XMPP over BOSH</a></li>
<li>0249 &#8211; Direct MUC Invitation</li>
</ul>
<p><strong style="font-size:18px;"><u>Documentation for project contributors</u></strong><br />
For developers interested in contributing to the Jaxl project, here is a list of insight documentation to get you started:</p>
<ul>
<li>Jaxl core workflow and architecture <em>(coming soon)</em></li>
<li>How to implement new XMPP extensions using Jaxl <em>(coming soon)</em></li>
</ul>
<p><strong style="font-size:18px;"><u>Useful Links</u></strong><br />
For live help and discussion join <a href="xmpp:jaxl@conference.psi-im.org?join">jaxl@conference.psi-im.org</a> chat room</p>
<ul>
<li><a href="http://groups.google.com/group/jaxl">Developer Mailing List</a></li>
<li><a href="http://code.google.com/p/jaxl/issues/list?can=1&#038;q=">Issue Tracker</a></li>
<li><a href="http://www.facebook.com/imjaxlim">Facebook</a></li>
<li><a href="http://twitter.com/imjaxlim">Twitter</a></li>
</ul>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F08%2Freleasing-jaxl-2-0-object-oriented-xmpp-framework-in-php%2F","http:\/\/github.com\/abhinavsingh\/JAXL","http:\/\/code.google.com\/p\/jaxl\/","xmpp:jaxl@conference.psi-im.org?join","http:\/\/groups.google.com\/group\/jaxl","http:\/\/code.google.com\/p\/jaxl\/issues\/list?can=1&#038;q=","http:\/\/www.facebook.com\/imjaxlim","http:\/\/twitter.com\/imjaxlim"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDEwLzA4L3JlbGVhc2luZy1qYXhsLTItMC1vYmplY3Qtb3JpZW50ZWQteG1wcC1mcmFtZXdvcmstaW4tcGhwLzx3cHRiPlJlbGVhc2luZyBKYXhsIDIuMCAmIzgyMTE7IE9iamVjdCBvcmllbnRlZCBYTVBQIGZyYW1ld29yayBpbiBQSFA8d3B0Yj5odHRwOi8vYWJoaW5hdnNpbmdoLmNvbS9ibG9nPHdwdGI%2BQWJoaSYjMDM5O3MgV2VibG9n";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2009/01/introducing-jaxl-open-source-jabber-xmpp-library/" title="Introducing JAXL &#8211; Open Source Jabber XMPP Library">Introducing JAXL &#8211; Open Source Jabber XMPP Library</a> (92)</li><li><a href="http://abhinavsingh.com/blog/2010/08/php-code-setup-and-demo-of-jaxl-boshchat-application/" title="PHP Code, Setup and Demo of Jaxl boshchat application">PHP Code, Setup and Demo of Jaxl boshchat application</a> (80)</li><li><a href="http://abhinavsingh.com/blog/2010/01/get-real-time-system-server-load-notification-on-any-im-using-php-and-xmpp/" title="Get real time system &amp; server load notification on any IM using PHP and XMPP">Get real time system &amp; server load notification on any IM using PHP and XMPP</a> (20)</li><li><a href="http://abhinavsingh.com/blog/2010/01/get-lyrics-for-any-song-using-xmpp-and-php-right-into-your-im-add-lyricsflygtalkbots-com/" title="Get lyrics for any song using XMPP and PHP right into your IM &#8211; Add lyricsfly@gtalkbots.com">Get lyrics for any song using XMPP and PHP right into your IM &#8211; Add lyricsfly@gtalkbots.com</a> (17)</li><li><a href="http://abhinavsingh.com/blog/2009/09/5-exciting-gaming-bots-you-can-create-using-jaxl-jabber-xmpp-library-in-php/" title="5 exciting (gaming) bots you can create using Jaxl (Jabber XMPP Library) in PHP">5 exciting (gaming) bots you can create using Jaxl (Jabber XMPP Library) in PHP</a> (23)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2010/08/releasing-jaxl-2-0-object-oriented-xmpp-framework-in-php/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Introducing WP-Chat :: XMPP Chat plugin for WordPress</title>
		<link>http://abhinavsingh.com/blog/2010/07/introducing-wp-chat-xmpp-chat-plugin-for-wordpress/</link>
		<comments>http://abhinavsingh.com/blog/2010/07/introducing-wp-chat-xmpp-chat-plugin-for-wordpress/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 21:25:05 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[XMPP]]></category>
		<category><![CDATA[JAXL]]></category>
		<category><![CDATA[MemChat]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=617</guid>
		<description><![CDATA[WP-Chat plugin embeds Jaxl IM (Instant Messenger for the web) for wordpress blogs. It runs across all major browsers and built upon XMPP protocol. It is a hosted solution from Jaxl.im empowering real time communication between you and your site visitors. It expects no software or hardware pre-requisites from your site servers or users. Above [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F07%2Fintroducing-wp-chat-xmpp-chat-plugin-for-wordpress%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F07%2Fintroducing-wp-chat-xmpp-chat-plugin-for-wordpress%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=JAXL,MemChat,WordPress,XMPP&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>WP-Chat plugin embeds Jaxl IM (Instant Messenger for the web) for wordpress blogs. It runs across all major browsers and built upon XMPP protocol. It is a hosted solution from <a href="http://jaxl.im">Jaxl.im</a> empowering real time communication between you and your site visitors. It expects no software or hardware pre-requisites from your site servers or users. Above all it&#8217;s free!</p>
<p><strong style="font-size:18px;"><u>Overview:</u></strong></p>
<ul>
<li>Supports for all major browser including Firefox, Chrome, Safari and IE</li>
<li>Embeddable on all blogs, forums, personal, social and enterprise sites</li>
<li>Built using XMPP protocol (backbone for facebook and google chats)</li>
<li>Hosted dashboard for site admins and IM users</li>
<li>Pluggable and Skinnable using developer api</li>
<li>Connect with you desktop IM clients (e.g. Pidgin, PSI, &#8230;)</li>
</ul>
<p><strong style="font-size:18px;"><u>History:</u></strong><br />
In two of my previous post (<a href="http://abhinavsingh.com/blog/2009/11/introducing-memchat-open-source-group-chat-framework-in-php-supporting-memcached-apc-sqlite-flat-files-and-mysql/">Introducing MemChat</a> and <a href="http://abhinavsingh.com/blog/2010/01/jaxl-bosh-demo-im-chat-client-for-all-wordpress-blogs/">Jaxl BOSH Demo</a>), I discussed and demoed a very early version of WP Chat plugin. In past 3 months, work has been done to make WP Chat generic enough so that it can be embedded across all kind of blogs, forums, social, personal and enterprise level websites. As of today, the product is named as &#8220;<a href="http://im.jaxl.im/">Jaxl IM (Instant Messenger for the web)</a>&#8221; and made available as &#8220;<a href="http://wordpress.org/extend/plugins/wp-chat">WP-Chat</a>&#8221; for the wordpress users.</p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F07%2Fintroducing-wp-chat-xmpp-chat-plugin-for-wordpress%2F","http:\/\/jaxl.im","http:\/\/im.jaxl.im\/","http:\/\/wordpress.org\/extend\/plugins\/wp-chat"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDEwLzA3L2ludHJvZHVjaW5nLXdwLWNoYXQteG1wcC1jaGF0LXBsdWdpbi1mb3Itd29yZHByZXNzLzx3cHRiPkludHJvZHVjaW5nIFdQLUNoYXQgOjogWE1QUCBDaGF0IHBsdWdpbiBmb3IgV29yZFByZXNzPHdwdGI%2BaHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZzx3cHRiPkFiaGkmIzAzOTtzIFdlYmxvZw%3D%3D";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2011/04/jaxl-library-list-of-available-hooks-for-various-xmpp-events/" title="JAXL library &#8211; List of available hooks for various XMPP events">JAXL library &#8211; List of available hooks for various XMPP events</a> (3)</li><li><a href="http://abhinavsingh.com/blog/2010/08/php-code-setup-and-demo-of-jaxl-boshchat-application/" title="PHP Code, Setup and Demo of Jaxl boshchat application">PHP Code, Setup and Demo of Jaxl boshchat application</a> (80)</li><li><a href="http://abhinavsingh.com/blog/2010/08/releasing-jaxl-2-0-object-oriented-xmpp-framework-in-php/" title="Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP">Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP</a> (6)</li><li><a href="http://abhinavsingh.com/blog/2010/01/jaxl-bosh-demo-im-chat-client-for-all-wordpress-blogs/" title="JAXL BOSH Demo: IM chat client for all Wordpress blogs">JAXL BOSH Demo: IM chat client for all Wordpress blogs</a> (35)</li><li><a href="http://abhinavsingh.com/blog/2010/01/get-real-time-system-server-load-notification-on-any-im-using-php-and-xmpp/" title="Get real time system &amp; server load notification on any IM using PHP and XMPP">Get real time system &amp; server load notification on any IM using PHP and XMPP</a> (20)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2010/07/introducing-wp-chat-xmpp-chat-plugin-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>46</slash:comments>
		</item>
		<item>
		<title>Setting up ejabberd 2.1.x development environment on Ubuntu</title>
		<link>http://abhinavsingh.com/blog/2010/03/setting-up-ejabberd-2-1-x-development-environment-on-ubuntu/</link>
		<comments>http://abhinavsingh.com/blog/2010/03/setting-up-ejabberd-2-1-x-development-environment-on-ubuntu/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 21:04:13 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[XMPP]]></category>
		<category><![CDATA[ejabberd]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=587</guid>
		<description><![CDATA[apt-get provide a convenient way of installing ejabberd on Ubuntu distributions. However, if you are an erlang developer and looking to write custom ejabberd modules, you might want to install ejabberd from the source code. Checkout ejabberd source To start with lets grab the ejabberd 2.1.x branch source code: sudo apt-get install git-core git clone [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F03%2Fsetting-up-ejabberd-2-1-x-development-environment-on-ubuntu%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F03%2Fsetting-up-ejabberd-2-1-x-development-environment-on-ubuntu%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=ejabberd,Ubuntu,XMPP&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><code>apt-get</code> provide a convenient way of installing <code>ejabberd</code> on <code>Ubuntu</code> distributions. However, if you are an <code>erlang</code> developer and looking to write custom ejabberd modules, you might want to install ejabberd from the source code.</p>
<p><strong style="font-size:18px;"><u>Checkout ejabberd source</u></strong><br />
To start with lets grab the ejabberd 2.1.x branch source code:</p>
<ul>
<li>sudo apt-get install git-core</li>
<li>git clone git://git.process-one.net/ejabberd/mainline.git ejabberd</li>
<li>cd ejabberd</li>
<li>git checkout -b 2.1.x origin/2.1.x</li>
<li>cd src</li>
</ul>
<p><strong style="font-size:18px;"><u>Installing pre-requisites</u></strong><br />
Lets setup necessary pre-requisites before compiling ejabberd source code:</p>
<ul>
<li>sudo apt-get install build-essential</li>
<li>sudo apt-get install automake autoconf</li>
<li>sudo apt-get install erlang erlang-manpages</li>
<li>sudo apt-get install libexpat1-dev zlib1g-dev libssl-dev</li>
</ul>
<p><strong style="font-size:18px;"><u>Compiling ejabberd source code</u></strong><br />
Compiling and installing is dead simple:</p>
<ul>
<li>./configure</li>
<li>make</li>
<li>sudo make install</li>
</ul>
<p><strong style="font-size:18px;"><u>Setting up administration account</u></strong><br />
By now we have ejabberd server setup on our ubuntu box. Lets setup the admin account:</p>
<ul>
<li>sudo ejabberdctl start</li>
<li>sudo ejabberdctl register admin localhost password</li>
<li>sudo vim /etc/ejabberd/ejabberd.cfg</li>
<li>Add following configurations if not already present:
<pre name="code" class="php">{acl, admin, {user, "admin", "localhost"}}.
{loglevel, 5}. %% Log level while development</pre>
</li>
<li>sudo ejabberdctl restart</li>
<li>Visit ejabberd admin panel: http://localhost:5280/admin</li>
<li>When prompted enter username as <code>admin@localhost</code> and the password you chose above while registering admin account</li>
</ul>
<p><strong style="font-size:18px;"><u>Resolving startup errors</u></strong><br />
You might see a few error reports in logs or elsewhere while starting ejabberd server:</p>
<ul>
<li>
<pre class="php" name="code">/sbin/ejabberdctl: 340: cannot create //var/lock/ejabberdctl/ejabberdctl-1: Directory nonexistent</pre>
</li>
<li>
<pre class="php" name="code">=ERROR REPORT==== 2010-03-29 21:53:03 ===
C(<0.995.0>:ejabberd_captcha:331) : The option captcha_cmd is not configured, but some module wants to use the CAPTCHA feature.</pre>
</li>
<li>
<pre class="php" name="code">=INFO REPORT==== 2010-03-29 21:53:03 ===
I(<0.780.0>:ejabberd_rdbms:37) : ejabberd has not been compiled with relational database support. Skipping database startup.</pre>
</li>
</ul>
<p>Here is how you can resolve the above errors:</p>
<ul>
<li>sudo mkdir /var/lock/ejabberdctl/ejabberdctl-1</li>
<li>Add following line in <code>ejabberd.cfg</code>
<pre class="php" name="code">{captcha_cmd, "/lib/ejabberd/priv/bin/captcha.sh"}.</pre>
<p> Replace <code>/lib/ejabberd/priv/bin/captcha.sh</code> with path to <code>/ejabberd/tools/captcha.sh</code></li>
</ul>
<p><strong style="font-size:18px;"><u>Getting started with ejabberd development</u></strong><br />
Below are links to a few useful resources to get you started with erlang and ejabberd module development:</p>
<ul>
<li>Erlang programming rules and conventions: <a href="http://www.erlang.se/doc/programming_rules.shtml">http://www.erlang.se/doc/programming_rules.shtml</a></li>
<li>Erlang documentation: <a href="http://www.erlang.org/doc">http://www.erlang.org/doc</a></li>
<li>Ejabberd module development wiki: <a href="http://www.process-one.net/en/wiki/ejabberd_module_development">http://www.process-one.net/en/wiki/ejabberd_module_development</a></li>
<li>Ejabberd documentation: <a href="https://support.process-one.net/doc/display/MESSENGER/ejabberd">https://support.process-one.net/doc/display/MESSENGER/ejabberd</a></li>
</ul>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F03%2Fsetting-up-ejabberd-2-1-x-development-environment-on-ubuntu%2F","http:\/\/www.erlang.se\/doc\/programming_rules.shtml","http:\/\/www.erlang.org\/doc","http:\/\/www.process-one.net\/en\/wiki\/ejabberd_module_development","https:\/\/support.process-one.net\/doc\/display\/MESSENGER\/ejabberd"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDEwLzAzL3NldHRpbmctdXAtZWphYmJlcmQtMi0xLXgtZGV2ZWxvcG1lbnQtZW52aXJvbm1lbnQtb24tdWJ1bnR1Lzx3cHRiPlNldHRpbmcgdXAgZWphYmJlcmQgMi4xLnggZGV2ZWxvcG1lbnQgZW52aXJvbm1lbnQgb24gVWJ1bnR1PHdwdGI%2BaHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZzx3cHRiPkFiaGkmIzAzOTtzIFdlYmxvZw%3D%3D";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2011/04/jaxl-library-list-of-available-hooks-for-various-xmpp-events/" title="JAXL library &#8211; List of available hooks for various XMPP events">JAXL library &#8211; List of available hooks for various XMPP events</a> (3)</li><li><a href="http://abhinavsingh.com/blog/2010/08/php-code-setup-and-demo-of-jaxl-boshchat-application/" title="PHP Code, Setup and Demo of Jaxl boshchat application">PHP Code, Setup and Demo of Jaxl boshchat application</a> (80)</li><li><a href="http://abhinavsingh.com/blog/2010/08/releasing-jaxl-2-0-object-oriented-xmpp-framework-in-php/" title="Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP">Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP</a> (6)</li><li><a href="http://abhinavsingh.com/blog/2010/07/introducing-wp-chat-xmpp-chat-plugin-for-wordpress/" title="Introducing WP-Chat :: XMPP Chat plugin for Wordpress">Introducing WP-Chat :: XMPP Chat plugin for Wordpress</a> (46)</li><li><a href="http://abhinavsingh.com/blog/2010/04/setting-nginx-php-fastcgi-and-xcache-on-a-new-ubuntu/" title="Setting Nginx, PHP Fastcgi and XCache on a new Ubuntu">Setting Nginx, PHP Fastcgi and XCache on a new Ubuntu</a> (5)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2010/03/setting-up-ejabberd-2-1-x-development-environment-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>JAXL BOSH Demo: IM chat client for all WordPress blogs</title>
		<link>http://abhinavsingh.com/blog/2010/01/jaxl-bosh-demo-im-chat-client-for-all-wordpress-blogs/</link>
		<comments>http://abhinavsingh.com/blog/2010/01/jaxl-bosh-demo-im-chat-client-for-all-wordpress-blogs/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 20:53:30 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[XMPP]]></category>
		<category><![CDATA[Bosh]]></category>
		<category><![CDATA[Demo]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=576</guid>
		<description><![CDATA[Have you ever wished of a wordpress plugin capable of providing a facebook style chat bar on your blog post. In this blog post, I will lay down the details of how Jaxl&#8216;s bosh support comes in handy for building such browser based real time application. Specifically, I will explain how I achieved building a [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F01%2Fjaxl-bosh-demo-im-chat-client-for-all-wordpress-blogs%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F01%2Fjaxl-bosh-demo-im-chat-client-for-all-wordpress-blogs%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=Bosh,Demo,PHP,WordPress,XMPP&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Have you ever wished of a wordpress plugin capable of providing a facebook style chat bar on your blog post. In this blog post, I will lay down the details of how <a href="http://code.google.com/p/jaxl">Jaxl</a>&#8216;s <a href="http://xmpp.org/extensions/xep-0206.html">bosh</a> support comes in handy for building such browser based real time application. Specifically, I will explain how I achieved building a plugin for my wordpress blog. If everything goes perfect over next few weeks, this plugin might be submitted in wordpress plugin&#8217;s directory.</p>
<p><strong style="font-size:18px;"><u>Jaxl BOSH Support Framework</u></strong><br />
Jaxl BOSH support comprise of three main parts:</p>
<ul>
<li><u>jaxl.jquery.js:</u> JQuery extension written for Jaxl bosh support</li>
<li><u>jaxl4bosh.class.php:</u> Connection manager in PHP</li>
<li><u>jaxl UI:</u> Integrated UI framework for changing your application skin on the fly. Your application skin can be a simple <a href="http://facebook.com">facebook</a> style chat bar (as on this page) or <a href="http://chesspark.com">chesspark</a> style whole html page</li>
</ul>
<p><code>jaxl.jquery.js</code> is responsible for initiating and maintaining a connection between the browser and the PHP connection manager. While <code>jaxl4bosh.class.php</code> implements the BOSH protocol and maintain a persistent connection with the jabber server.</p>
<p>jaxl.jquery.js provide a few basic methods like:</p>
<ul>
<li><u>jaxl.connect:</u> Call for initiating the connection</li>
<li><u>jaxl.sendMessage:</u> Call for sending a message to other jid&#8217;s</li>
<li><u>jaxl.ping:</u> Call to maintain the connection and gather any incoming data</li>
<li><u>jaxl.disconnect:</u> Call for disconnecting</li>
</ul>
<p>jaxl4bosh.class.php provide wordpress style filter/hooks which can be used to modify every incoming and outgoing messages.</p>
<ul>
<li><u>jaxl_pre_connect:</u> Call to perform initialization before jaxl connects to jabber server</li>
<li><u>jaxl_post_connect:</u> Call to perform shutdown after jaxl is connected to jabber server</li>
<li><u>jaxl_send_message:</u> Call to perform actions on outgoing messages from jaxl</li>
<li><u>jaxl_recv_message:</u> Call to perform actions on incoming messages to jaxl</li>
<li><u>jaxl_send_presence:</u> Call to perform actions on outgoing presence from jaxl</li>
<li><u>jaxl_recv_presence:</u> Call to perform actions on incoming presence from jaxl</li>
<li><u>jaxl_pre_disconnect:</u> Call to perform initialization before jaxl disconnects to jabber server</li>
<li><u>jaxl_post_disconnect:</u> Call to perform shutdown after jaxl is disconnected to jabber server</li>
</ul>
<p><strong style="font-size:18px;"><u>Jaxl and WordPress</u></strong><br />
Using Jaxl bosh support require you to only edit the configuration file. Here are the config variables:</p>
<pre name="code" class="php">        // JAXL config
        define('JAXL_BOSH_HOST', 'localhost');
        define('JAXL_BOSH_SERVER', 'localhost');
        define('JAXL_BOSH_URL', 'http://localhost:7070/http-bind/');
        define('JAXL_ADMIN_JID', 'admin@localhost');
</pre>
<p>You can configure Jaxl to use any of the available <a href="http://xmpp.org/services/">public xmpp services</a>. However, I choose to host my own jabber server for my blog.</p>
<p><code>JAXL_ADMIN_JID</code> is the admin jid to which Jaxl should route all incoming messages, added specifically for wordpress related requirement. PHP connection manager can be extended to route different chat sessions to different admins.</p>
<p><code>jaxl_recv_message</code> handler is used to embed smiley&#8217;s and youtube videos by parsing the incoming chat messages.<br />
<img src="http://abhinavsingh.com/blog/wp-content/uploads/2010/01/jaxl-bosh-support-hook-demo-youtube-smiley.png" alt="jaxl-bosh-support-hook-demo-youtube-smiley" title="jaxl-bosh-support-hook-demo-youtube-smiley" width="413" height="407" class="aligncenter size-full wp-image-577" /></p>
<p>A few other hooks like <code>jaxl_post_connect</code> are used to notify <code>JAXL_ADMIN_JID</code> about the newly connected user.</p>
<p><strong style="font-size:18px;"><u>Admin Screen</u></strong><br />
Below is a screen shot of how an admin desktop will look like while chatting with his site visitors:<br />
<img src="http://abhinavsingh.com/blog/wp-content/uploads/2010/01/Admin-screenshot-jaxl-bosh-support.png" alt="Admin-screenshot-jaxl-bosh-support" title="Admin-screenshot-jaxl-bosh-support" width="413" height="602" class="aligncenter size-full wp-image-579" /></p>
<p>Let me know if you are having any issues chatting using the chat bar at the bottom of the page. Code and installation might be buggy at times, and would appreciate any help from you on it.</p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F01%2Fjaxl-bosh-demo-im-chat-client-for-all-wordpress-blogs%2F","http:\/\/code.google.com\/p\/jaxl","http:\/\/xmpp.org\/extensions\/xep-0206.html","http:\/\/facebook.com","http:\/\/chesspark.com","http:\/\/xmpp.org\/services\/"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDEwLzAxL2pheGwtYm9zaC1kZW1vLWltLWNoYXQtY2xpZW50LWZvci1hbGwtd29yZHByZXNzLWJsb2dzLzx3cHRiPkpBWEwgQk9TSCBEZW1vOiBJTSBjaGF0IGNsaWVudCBmb3IgYWxsIFdvcmRQcmVzcyBibG9nczx3cHRiPmh0dHA6Ly9hYmhpbmF2c2luZ2guY29tL2Jsb2c8d3B0Yj5BYmhpJiMwMzk7cyBXZWJsb2c%3D";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2010/08/php-code-setup-and-demo-of-jaxl-boshchat-application/" title="PHP Code, Setup and Demo of Jaxl boshchat application">PHP Code, Setup and Demo of Jaxl boshchat application</a> (80)</li><li><a href="http://abhinavsingh.com/blog/2009/07/how-to-add-wordpress-like-add_filter-hooks-in-your-php-framework/" title="How to add wordpress like add_filter hooks in your PHP framework">How to add wordpress like add_filter hooks in your PHP framework</a> (18)</li><li><a href="http://abhinavsingh.com/blog/2010/08/releasing-jaxl-2-0-object-oriented-xmpp-framework-in-php/" title="Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP">Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP</a> (6)</li><li><a href="http://abhinavsingh.com/blog/2010/07/introducing-wp-chat-xmpp-chat-plugin-for-wordpress/" title="Introducing WP-Chat :: XMPP Chat plugin for Wordpress">Introducing WP-Chat :: XMPP Chat plugin for Wordpress</a> (46)</li><li><a href="http://abhinavsingh.com/blog/2010/01/get-real-time-system-server-load-notification-on-any-im-using-php-and-xmpp/" title="Get real time system &amp; server load notification on any IM using PHP and XMPP">Get real time system &amp; server load notification on any IM using PHP and XMPP</a> (20)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2010/01/jaxl-bosh-demo-im-chat-client-for-all-wordpress-blogs/feed/</wfw:commentRss>
		<slash:comments>35</slash:comments>
		</item>
		<item>
		<title>Get real time system &amp; server load notification on any IM using PHP and XMPP</title>
		<link>http://abhinavsingh.com/blog/2010/01/get-real-time-system-server-load-notification-on-any-im-using-php-and-xmpp/</link>
		<comments>http://abhinavsingh.com/blog/2010/01/get-real-time-system-server-load-notification-on-any-im-using-php-and-xmpp/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 21:54:15 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[XMPP]]></category>
		<category><![CDATA[JAXL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=571</guid>
		<description><![CDATA[There are various system and server related information which server administrators always need to have as soon as possible, infact I must say in real time. There are several open and closed source softwares in the market which can generate almost real time notifications for you. Most famous one being Nagios. In this blog post [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F01%2Fget-real-time-system-server-load-notification-on-any-im-using-php-and-xmpp%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F01%2Fget-real-time-system-server-load-notification-on-any-im-using-php-and-xmpp%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=JAXL,PHP,XMPP&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>There are various system and server related information which server administrators always need to have as soon as possible, infact I must say in real time. There are several open and closed source softwares in the market which can generate almost real time notifications for you. Most famous one being <a href="http://www.nagios.org/">Nagios</a>. In this blog post I will discuss, how to generate real time system notifications using PHP and <a href="http://xmpp.org">XMPP</a>. Specifically, I will present sample script using <a href="http://code.google.com/p/jaxl">Jaxl</a> (Jabber XMPP Client Library) for generating real time system load notifications, which can be received using any Instant Messengers.</p>
<p><strong style="font-size:18px;"><u>/proc/loadavg</u></strong><br />
We will be using system <code>/proc/loadavg</code> file to get real time system load information. If you are unaware about this file, here is in brief how this file is helpful to us:</p>
<pre class="php" name="code">sabhinav:~# cat /proc/loadavg
0.22 0.12 0.09 1/68 12621</pre>
<p>where first three columns measure the CPU and IO utilization of last one, five and 10 minute periods. The fourth column shows the number of currently running processes and the total number of processes. The last column displays the last process ID used.</p>
<p><strong style="font-size:18px;"><u>jaxl4serveradmins.class.php</u></strong><br />
We will be using Jaxl PHP client library for handling the XMPP part. <code>jaxl4serveradmins.class.php</code> is an extension to Jaxl, providing various server administration helper function. Below is the code for server administration extension:</p>
<pre class="php" name="code">  include_once("xmpp.class.php");

  define('JAXL_SERVER_ADMIN', 'mailsforabhinav@gmail.com');
  define('JAXL_SERVER_LOAD_POLL_INTERVAL', 10);

  class JAXL extends XMPP {

    function eventMessage($fromJid, $content, $offline = FALSE) {
    }

    function eventPresence($fromJid, $status, $photo) {
    }

    function eventNewEMail($total,$thread,$url,$participation,$messages,$date,$senders,$labels,$subject,$snippet) {
      // Not used here. See jaxl4gmail.class.php for it's use case
    }

    function setStatus() {
      // Set a custom status or use $this->status
      $this->sendStatus($this->status);
      print "Setting Status...\n";
      print "Done\n";

      $this->addJob(JAXL_SERVER_LOAD_POLL_INTERVAL, array($this, 'parseServerLoad'));
    }

    function parseServerLoad() {
      $loadavg = file_get_contents('/proc/loadavg');
      $this->sendMessage(JAXL_SERVER_ADMIN, $loadavg);
    }

  }</pre>
<p>I have utilized <code>addJob()</code> method provided by Jaxl library, using which you can specify a callback to be called after every N seconds (in short a periodic cron). Here we add a periodic job to be runned every JAXL_SERVER_LOAD_POLL_INTERVAL seconds. <code>parseServerLoad()</code> method is called as the callback function.</p>
<pre class="php" name="code">$this->addJob(JAXL_SERVER_LOAD_POLL_INTERVAL, array($this, 'parseServerLoad'));</pre>
<p>To keep the demo simple, I am simply sending the content of <code>/proc/loadavg</code> file as a message to server admins.</p>
<pre class="php" name="code">    function parseServerLoad() {
      $loadavg = file_get_contents('/proc/loadavg');
      $this->sendMessage(JAXL_SERVER_ADMIN, $loadavg);
    }</pre>
<p><strong style="font-size:18px;"><u>Running it for your servers:</u></strong><br />
Follow the following steps to get this started on your server (only Unix, no Windows):</p>
<ul>
<li>Checkout from Jaxl trunk
<pre class="php" name="code">sabhinav:~# sudo svn checkout http://jaxl.googlecode.com/svn/trunk/ jaxl-read-only</pre>
</li>
<li>Enter checked out directory
<pre class="php" name="code">sabhinav:~# cd jaxl-read-only</pre>
</li>
<li>Enter your server admin IM contact details
<pre class="php" name="code">sabhinav:~# sudo vim config.ini.php
define('JAXL_SERVER_ADMIN', 'webmaster@foobar.com');</pre>
</li>
<li>Enable server administration extension
<pre class="php" name="code">sabhinav:~# sudo vim index.php
include_once("jaxl4serveradmins.class.php"); // include_once("jaxl.class.php");</pre>
</li>
<li>Wroom Wroom, start Jaxl
<pre class="php" name="code">sabhinav:~# sudo php index.php
Starting TLS Encryption...
Attempting PLAIN Authentication...
Starting Session...
Requesting Feature List...
Requesting Roster List...
Setting Status...
Done
</pre>
</li>
</ul>
<p>Tail the jaxl log file in case you are facing any difficulties in the setup.
<pre class="php" name="code">sabhinav:~# tail -f log/logger.log</pre>
<p> You should also consider adding <code>/proc/</code> directory under <code>open_basedir</code> in <code>php.ini</code> file.</p>
<p><strong style="font-size:18px;"><u>Is it working?</u></strong><br />
If all is well configured server admins will start getting notifications every 10 seconds which is default value for JAXL_SERVER_LOAD_POLL_INTERVAL.<br />
<img src="http://abhinavsingh.com/blog/wp-content/uploads/2010/01/Jaxl4serveradmins.class.php-example-screenshot-for-system-load.png" alt="Jaxl4serveradmins.class.php example screenshot for system load" title="Jaxl4serveradmins.class.php example screenshot for system load" width="510" height="142" class="aligncenter size-full wp-image-572" /></p>
<p><strong style="font-size:18px;"><u>Writing custom notifications</u></strong><br />
Above I demonstrate how we can use XMPP and PHP to generate real time system notification. However, you may want to modify <code>parseServerLoad()</code> method to send notifications only when the server load exceeds a certain value. You may also want to add other methods which can notify you of various System and Server level parameters in a similar fashion. Below are a few useful system administration commands:</p>
<pre class="php" name="code">sabhinav:~# free -m
sabhinav:~# vmstat 1 20</pre>
<p><strong style="font-size:18px;"><u>Is it really real time?</u></strong><br />
Since, <code>parseServerLoad()</code> method polls for <code>/proc/loadavg</code> file every 10 seconds, this is not exactly real time. However you can configure JAXL_SERVER_LOAD_POLL_INTERVAL to make it poll faster. You can also use <a href="http://abhinavsingh.com/blog/2009/11/writing-a-custom-unix-style-tail-in-php-using-libevent-api-on-mac-os-x-10-5-x-and-other-platforms/">libevent extension</a> in PHP to make it real time in real sense.</p>
<p>Do let me know if you write any interesting functionality, I will be more than happy to include it as a part of current extension.</p>
<div id="paidTxtLinkAds">The <a href="http://www.testking.org">testking</a> offer complete learning of web development through the use of latest <a href="http://www.testking.org/VCP-410.htm">testking VCP-410</a> tutorials and other <a href="http://www.testking.org/640-802.htm">testking 640-802</a> php tools.</div>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F01%2Fget-real-time-system-server-load-notification-on-any-im-using-php-and-xmpp%2F","http:\/\/www.nagios.org\/","http:\/\/xmpp.org","http:\/\/code.google.com\/p\/jaxl","http:\/\/www.testking.org","http:\/\/www.testking.org\/VCP-410.htm","http:\/\/www.testking.org\/640-802.htm"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDEwLzAxL2dldC1yZWFsLXRpbWUtc3lzdGVtLXNlcnZlci1sb2FkLW5vdGlmaWNhdGlvbi1vbi1hbnktaW0tdXNpbmctcGhwLWFuZC14bXBwLzx3cHRiPkdldCByZWFsIHRpbWUgc3lzdGVtICZhbXA7IHNlcnZlciBsb2FkIG5vdGlmaWNhdGlvbiBvbiBhbnkgSU0gdXNpbmcgUEhQIGFuZCBYTVBQPHdwdGI%2BaHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZzx3cHRiPkFiaGkmIzAzOTtzIFdlYmxvZw%3D%3D";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2010/08/php-code-setup-and-demo-of-jaxl-boshchat-application/" title="PHP Code, Setup and Demo of Jaxl boshchat application">PHP Code, Setup and Demo of Jaxl boshchat application</a> (80)</li><li><a href="http://abhinavsingh.com/blog/2010/08/releasing-jaxl-2-0-object-oriented-xmpp-framework-in-php/" title="Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP">Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP</a> (6)</li><li><a href="http://abhinavsingh.com/blog/2010/01/get-lyrics-for-any-song-using-xmpp-and-php-right-into-your-im-add-lyricsflygtalkbots-com/" title="Get lyrics for any song using XMPP and PHP right into your IM &#8211; Add lyricsfly@gtalkbots.com">Get lyrics for any song using XMPP and PHP right into your IM &#8211; Add lyricsfly@gtalkbots.com</a> (17)</li><li><a href="http://abhinavsingh.com/blog/2009/01/introducing-jaxl-open-source-jabber-xmpp-library/" title="Introducing JAXL &#8211; Open Source Jabber XMPP Library">Introducing JAXL &#8211; Open Source Jabber XMPP Library</a> (92)</li><li><a href="http://abhinavsingh.com/blog/2011/04/jaxl-library-list-of-available-hooks-for-various-xmpp-events/" title="JAXL library &#8211; List of available hooks for various XMPP events">JAXL library &#8211; List of available hooks for various XMPP events</a> (3)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2010/01/get-real-time-system-server-load-notification-on-any-im-using-php-and-xmpp/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Get lyrics for any song using XMPP and PHP right into your IM &#8211; Add lyricsfly@gtalkbots.com</title>
		<link>http://abhinavsingh.com/blog/2010/01/get-lyrics-for-any-song-using-xmpp-and-php-right-into-your-im-add-lyricsflygtalkbots-com/</link>
		<comments>http://abhinavsingh.com/blog/2010/01/get-lyrics-for-any-song-using-xmpp-and-php-right-into-your-im-add-lyricsflygtalkbots-com/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 17:03:39 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[XMPP]]></category>
		<category><![CDATA[Gtalkbots]]></category>
		<category><![CDATA[JAXL]]></category>
		<category><![CDATA[lyricsfly]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=568</guid>
		<description><![CDATA[XMPP is soon finding it&#8217;s way into real time applications other than just chat. I have combined JAXL (Jabber XMPP client library written in PHP) and the API from lyricsfly.com to build a real time chat bot which can assist you with lyrics for any song. You can start using it by simply adding lyricsfly@gtalkbots.com [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F01%2Fget-lyrics-for-any-song-using-xmpp-and-php-right-into-your-im-add-lyricsflygtalkbots-com%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F01%2Fget-lyrics-for-any-song-using-xmpp-and-php-right-into-your-im-add-lyricsflygtalkbots-com%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=Gtalkbots,JAXL,lyricsfly,PHP,XMPP&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>XMPP is soon finding it&#8217;s way into real time applications other than just chat. I have combined <a href="http://code.google.com/p/jaxl">JAXL</a> (Jabber XMPP client library written in PHP) and the API from <a href="http://lyricsfly.com">lyricsfly.com</a> to build a real time chat bot which can assist you with lyrics for any song. You can start using it by simply adding lyricsfly@gtalkbots.com to your IM account (e.g. Gtalk, Jabber etc). In this blog post, I will explain in brief the working of lyricsfly bot and how you can integrate XMPP into your own application.</p>
<p><strong style="font-size:18px;"><u>Try out lyricsfly@gtalkbots.com</u></strong><br />
Follow the following steps to get the bot working for you:</p>
<ul>
<li>Login to your gtalk account using any of the IM available</li>
<li>Press Add Contact</li>
<li>Add <code>lyricsfly@gtalkbots.com</code> as your chat buddy</li>
<li>Send a chat message in following format &#8220;Song Title &#8211; Song Artist&#8221; e.g. &#8220;one &#8211; metallica&#8221;</li>
<li>You should see something like this: <img src="http://abhinavsingh.com/blog/wp-content/uploads/2010/01/lyricsfly@gtalkbots.com-Demo-for-one-metallica.png" alt="lyricsfly@gtalkbots.com Demo for &quot;one-metallica&quot;" title="lyricsfly@gtalkbots.com Demo for &quot;one-metallica&quot;" width="550" height="409" class="aligncenter size-full wp-image-569" /></li>
</ul>
<p><strong style="font-size:18px;"><u>Working of lyricsfly@gtalkbots.com with Jaxl</u></strong><br />
Here is in brief the working of lyricsfly bot using Jaxl client library:</p>
<ul>
<li>When someone sends a message like &#8220;one &#8211; metallica&#8221;  to the bot, <code>eventMessage()</code> method is called inside <code>jaxl.class.php</code></li>
<li>eventMessage then extracts the song title and artist name from the message using PHP explode. Filter the title and artist names for allowed characters.</li>
<li>eventMessage also calls lyricsfly API and fetch the lyrics. Finally it sends the lyrics as message to requester.</li>
<li>eventMessage also uses memcached to cache the lyrics. It decreases both response time and load on lyricsfly servers</li>
<li>Bot also keeps a count of number of queries from a particular user. Since it is still under development, currently there is a limit on number of lyrics you can fetch in a single day.</li>
</ul>
<p><strong style="font-size:18px;"><u>Making your own custom bot</u></strong></p>
<ul>
<li>Checkout latest from the trunk
<pre class="php" name="code">sabhinav$ svn checkout http://jaxl.googlecode.com/svn/trunk/ jaxl-read-only</li>
<li>Edit config file with your bot username, password and jabber servers</li>
<li>Run from command like
<pre class="php" name="code">php index.php</pre>
</li>
<li>To customize the bot modify <code>eventMessage</code> and <code>eventPresence</code> methods of Jaxl class inside <code>jaxl.class.php</code></li>
</ul>
<p>For a full fledged running bot example code, edit index.php and include<a href="http://abhinavsingh.com/blog/2009/01/how-to-get-dzone-feeds-as-im-using-jaxl-add-dzonegtalkbotscom/"> jaxl4dzone.class.php</a> instead of jaxl.class.php and re-run the bot.</p>
<p>Have fun and enjoy singing songs along with the lyrics.</p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F01%2Fget-lyrics-for-any-song-using-xmpp-and-php-right-into-your-im-add-lyricsflygtalkbots-com%2F","http:\/\/code.google.com\/p\/jaxl","http:\/\/lyricsfly.com"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDEwLzAxL2dldC1seXJpY3MtZm9yLWFueS1zb25nLXVzaW5nLXhtcHAtYW5kLXBocC1yaWdodC1pbnRvLXlvdXItaW0tYWRkLWx5cmljc2ZseWd0YWxrYm90cy1jb20vPHdwdGI%2BR2V0IGx5cmljcyBmb3IgYW55IHNvbmcgdXNpbmcgWE1QUCBhbmQgUEhQIHJpZ2h0IGludG8geW91ciBJTSAmIzgyMTE7IEFkZCBseXJpY3NmbHlAZ3RhbGtib3RzLmNvbTx3cHRiPmh0dHA6Ly9hYmhpbmF2c2luZ2guY29tL2Jsb2c8d3B0Yj5BYmhpJiMwMzk7cyBXZWJsb2c%3D";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2009/01/introducing-jaxl-open-source-jabber-xmpp-library/" title="Introducing JAXL &#8211; Open Source Jabber XMPP Library">Introducing JAXL &#8211; Open Source Jabber XMPP Library</a> (92)</li><li><a href="http://abhinavsingh.com/blog/2010/08/php-code-setup-and-demo-of-jaxl-boshchat-application/" title="PHP Code, Setup and Demo of Jaxl boshchat application">PHP Code, Setup and Demo of Jaxl boshchat application</a> (80)</li><li><a href="http://abhinavsingh.com/blog/2010/08/releasing-jaxl-2-0-object-oriented-xmpp-framework-in-php/" title="Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP">Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP</a> (6)</li><li><a href="http://abhinavsingh.com/blog/2010/01/get-real-time-system-server-load-notification-on-any-im-using-php-and-xmpp/" title="Get real time system &amp; server load notification on any IM using PHP and XMPP">Get real time system &amp; server load notification on any IM using PHP and XMPP</a> (20)</li><li><a href="http://abhinavsingh.com/blog/2011/04/jaxl-library-list-of-available-hooks-for-various-xmpp-events/" title="JAXL library &#8211; List of available hooks for various XMPP events">JAXL library &#8211; List of available hooks for various XMPP events</a> (3)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2010/01/get-lyrics-for-any-song-using-xmpp-and-php-right-into-your-im-add-lyricsflygtalkbots-com/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>How to use JAXL (Jabber XMPP Library in PHP) to import Gtalk contacts of any user</title>
		<link>http://abhinavsingh.com/blog/2009/11/how-to-use-jaxl-jabber-xmpp-library-in-php-to-import-gtalk-contacts-of-any-user/</link>
		<comments>http://abhinavsingh.com/blog/2009/11/how-to-use-jaxl-jabber-xmpp-library-in-php-to-import-gtalk-contacts-of-any-user/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 14:31:19 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[XMPP]]></category>
		<category><![CDATA[Gtalk]]></category>
		<category><![CDATA[JAXL]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=550</guid>
		<description><![CDATA[JAXL is an open source Jabber XMPP Client library written in PHP. It provides a self titled class JAXL which implements XMPP protocol. It can be extended to write custom event handler for every message or presence received. Developers are using JAXL for developing real time applications. Checkout 5 exciting gaming bots you can make [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F11%2Fhow-to-use-jaxl-jabber-xmpp-library-in-php-to-import-gtalk-contacts-of-any-user%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F11%2Fhow-to-use-jaxl-jabber-xmpp-library-in-php-to-import-gtalk-contacts-of-any-user%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=Gtalk,JAXL,XMPP&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://code.google.com/p/jaxl">JAXL</a> is an open source Jabber XMPP Client library written in PHP.  It provides a self titled class JAXL which implements XMPP protocol. It can be extended to write custom event handler for every message or presence received. Developers are using JAXL for developing real time applications. Checkout <a href="http://abhinavsingh.com/blog/2009/09/5-exciting-gaming-bots-you-can-create-using-jaxl-jabber-xmpp-library-in-php/">5 exciting gaming bots you can make using JAXL</a>.</p>
<p>However one thing which goes un-noticed is that JAXL can also be used to import Gtalk contacts of any user. This is infact one of the very first thing which JAXL class do, after successful authentication with the Gtalk servers i.e. import the authenticated user contact list. In this blog post I will demo a sample script to import any user contact list from google servers.</p>
<p><strong style="font-size:18px;"><u>Importing Gtalk contacts using JAXL</u></strong></p>
<ol>
<li>Download and extract <a href="http://jaxl.googlecode.com/files/jaxl-1.0.4.rar">jaxl-1.0.4.rar</a></li>
<li>Edit <code>config.ini.php</code> and update credentials of the user whose contact list we are trying to import:
<pre class="php" name="code">  $key = array("prod"=>array("user"=>"mailsforabhinav",
                             "pass"=>"xxxxxx",
                             "host"=>"talk.google.com",
                             "port"=>5222,
                             "domain"=>"gmail.com"
                            ),
</pre>
</li>
<li>Open <code>jaxl.class.php</code> and modify the code as below:
<pre class="php" name="code">    function setStatus() {
      // Set a custom status or use $this->status
      $this->sendStatus($this->status);
      print "Setting Status...\n";
      print_r($this->rosterlist); // Print the contact list on the console
      print "Done\n";
      exit;
    }
</pre>
</li>
<li>Finally run from command line to retrieve gtalk contacts of the authenticated user.
<pre class="php" name="code">php index.php</pre>
</li>
</ol>
<p>One can easily modify the above code to save user contacts in a database.<br />
Also one can echo <code>json_encode($this->rosterlist)</code> in response to an Ajax call from the browser.</p>
<p>Enjoy and leave your comments.</p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F11%2Fhow-to-use-jaxl-jabber-xmpp-library-in-php-to-import-gtalk-contacts-of-any-user%2F","http:\/\/code.google.com\/p\/jaxl","http:\/\/jaxl.googlecode.com\/files\/jaxl-1.0.4.rar"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDA5LzExL2hvdy10by11c2UtamF4bC1qYWJiZXIteG1wcC1saWJyYXJ5LWluLXBocC10by1pbXBvcnQtZ3RhbGstY29udGFjdHMtb2YtYW55LXVzZXIvPHdwdGI%2BSG93IHRvIHVzZSBKQVhMIChKYWJiZXIgWE1QUCBMaWJyYXJ5IGluIFBIUCkgdG8gaW1wb3J0IEd0YWxrIGNvbnRhY3RzIG9mIGFueSB1c2VyPHdwdGI%2BaHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZzx3cHRiPkFiaGkmIzAzOTtzIFdlYmxvZw%3D%3D";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2009/02/programatically-control-your-google-mails-using-jaxl-v-104/" title="Programatically control your google mails using JAXL v 1.0.4">Programatically control your google mails using JAXL v 1.0.4</a> (4)</li><li><a href="http://abhinavsingh.com/blog/2009/01/introducing-jaxl-open-source-jabber-xmpp-library/" title="Introducing JAXL &#8211; Open Source Jabber XMPP Library">Introducing JAXL &#8211; Open Source Jabber XMPP Library</a> (92)</li><li><a href="http://abhinavsingh.com/blog/2011/04/jaxl-library-list-of-available-hooks-for-various-xmpp-events/" title="JAXL library &#8211; List of available hooks for various XMPP events">JAXL library &#8211; List of available hooks for various XMPP events</a> (3)</li><li><a href="http://abhinavsingh.com/blog/2010/08/php-code-setup-and-demo-of-jaxl-boshchat-application/" title="PHP Code, Setup and Demo of Jaxl boshchat application">PHP Code, Setup and Demo of Jaxl boshchat application</a> (80)</li><li><a href="http://abhinavsingh.com/blog/2010/08/releasing-jaxl-2-0-object-oriented-xmpp-framework-in-php/" title="Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP">Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP</a> (6)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2009/11/how-to-use-jaxl-jabber-xmpp-library-in-php-to-import-gtalk-contacts-of-any-user/feed/</wfw:commentRss>
		<slash:comments>40</slash:comments>
		</item>
		<item>
		<title>Programatically control your google mails using JAXL v 1.0.4</title>
		<link>http://abhinavsingh.com/blog/2009/02/programatically-control-your-google-mails-using-jaxl-v-104/</link>
		<comments>http://abhinavsingh.com/blog/2009/02/programatically-control-your-google-mails-using-jaxl-v-104/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 18:10:30 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[XMPP]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Gmail]]></category>
		<category><![CDATA[Gtalk]]></category>
		<category><![CDATA[JAXL]]></category>
		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=247</guid>
		<description><![CDATA[Google has released an API for almost all of their products including maps, feedburner and gadgets. However one of the API&#8217;s which every developer would have loved to make use of is &#8220;Google Mail API&#8221; which is still missing (available for premium google apps user only). Here in this post I would demonstrate how one [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F02%2Fprogramatically-control-your-google-mails-using-jaxl-v-104%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F02%2Fprogramatically-control-your-google-mails-using-jaxl-v-104%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=API,Gmail,Gtalk,JAXL,Open+Source,XMPP&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Google has released an API for almost all of their products including maps, feedburner and gadgets. However one of the API&#8217;s which every developer would have loved to make use of is &#8220;Google Mail API&#8221; which is still missing (available for premium google apps user only). Here in this post I would demonstrate how one can programatically control his/her google mails using JAXL without being a premium user of google mail account.</p>
<p>For those who have landed on this post straight and have little knowledge about what JAXL is &#8220;<em>JAXL stands for Jabber XMPP Library and for fun you may call it Just Another XMPP Library. It is written in PHP and can be downloaded from <a href="http://code.google.com/p/jaxl">http://code.google.com/p/jaxl</a></em>&#8220;. To know more about JAXL, read the <a href="http://abhinavsingh.com/blog/2009/01/introducing-jaxl-open-source-jabber-xmpp-library/">introductory post</a> here. If you want to dig deep and know how JAXL works, read the <a href="http://abhinavsingh.com/blog/2009/01/behind-the-scenes-how-and-what-xmls-are-exchanged-by-jaxl/">gtalk case study</a> here. Finally, after reading this post you may also want to check how you can <a href="http://abhinavsingh.com/blog/2009/01/how-to-get-dzone-feeds-as-im-using-jaxl-add-dzonegtalkbotscom/">fetch any social networking feed</a> right into your gtalk messenger using JAXL.</p>
<p>Version 1.0.4 of JAXL included support for &#8220;<a href="http://code.google.com/apis/talk/jep_extensions/gmail.html">Gmail Notification Extension of XMPP</a>&#8220;. If you are a daily Gtalk user like me, then you have surely seen this extension in action. Just recall Gtalk notifying you of a new mail in your inbox, through a pop-up in the bottom right corner. Also those who see this in action everyday will agree with me that this notification comes even before the mail has actually appeared in you inbox. Simply because of the <a href="http://en.wikipedia.org/wiki/Push_technology">PUSH technology</a> used by XMPP protocol.</p>
<p>So why would you in first place be interested in accessing your google mails programatically. A quick thought on this brings me to the following real life scenarios:</p>
<ul>
<li>Suppose your are out of vacation and you want to set a custom auto-reply message for your family and friends, while you want to set a general out-of-office message for your colleagues. The limitation in gmail is that you can&#8217;t really do this. Further in this post, I will show you how can you achieve this using JAXL.</li>
<li>Suppose you are a google app user and your company has organized an online programming contest. Further you want to mail each question to the contestants only if they has answered the previous question. JAXL provide you a way to access key information about your incoming mails like: sender email id, subject, number of threads in the mail, time at which  mail was sent, mail url and mail snippet. Which is enough for you to code a bot which can check for incoming mail and then send in next question to the contestant who sent this mail</li>
<ol>
Further there can be a thousand use cases where you would you like to have such a control over you google mails but before discussing them, lets see a demonstration on how can we use JAXL to achieve this.</p>
<p><strong style="font-size:18px;"><u>Sending Custom Auto-Reply Mails using JAXL</u></strong><br />
Along with extendable functions like <strong>eventMessage()</strong> and <strong>eventPresence()</strong>, JAXL&#8217;s latest version now also provide another extendable function called <strong>eventNewEMail()</strong>. So everytime you receive a new mail(s) in your google account, the control is passed to this function along with all informations about the incoming mails.</p>
<p>Various data passed to this function are:</p>
<ul>
<li>$total: Tells you about total number of unread mails.</li>
<li>$thread: The thread id of all the unread threads. Note: In Gmail you have threads in your inbox which can contain more than a single mail.</li>
<li>$url: The mail.google.com url for the new mail</li>
<li>$participation: This can be 0, 1 or 2. 0 indicates that you have not participated, 1 indicates that you are one of the many recipients and 2 indicates that you are the sole recipient for messages in this thread</li>
<li>$message: The number of messages in the thread. For instance you can have more than one unread mail in a thread.</li>
<li>$date: A timestamp of the most recent unread message, in milliseconds since the UNIX epoch</li>
<li>$senders: Email Id of all the senders in the current thread</li>
<li>$labels: Label if any to which this mail thread belongs to</li>
<li>$subject: The subject of the mail threads</li>
<li>$snippet: The mail snippet of the incoming mail</li>
</ul>
<p>So thats a lot of information really, with which we can automate things to a certain extent. Lets see how I use it to send custom auto-reply mails when I am out on vacation. Here is the extendable jaxl class for gmail:</p>
<p><strong>jaxl4gmail.class.php</strong> (<a href="http://code.google.com/p/jaxl/source/browse/trunk/jaxl4gmail.class.php">Download</a>)</p>
<pre name="code" class="php">
  /* Include PHP Mailer Class */
  include_once("class.phpmailer.php");

  /* Include XMPP Class */
  include_once("xmpp.class.php");

  class JAXL extends XMPP {

    /* Define custom mail groups */
    var $family = array("mom@gmail.com","dad@gmail.com");
    var $colleague = array("boss@company.com","manager@company.com");

    /* Define custom mail subject and message */
    var $familySubject = "Hi, Will get back to you";
    var $familyMessage = "Hey, I am currently out on vacation at my grannies house in Delhi. I will return back home by next monday.<br/>Reach out to me at +91-987654321.<br/><br/>With Love,<br/>Abhinav Singh";

    /* Define custom mail subject and message */
    var $colleagueSubject = "[Auto-Reply] Out of Office";
    var $colleagueMessage = "Hi, I am on vacation in my village with very limited access to internet and phone. I will return back home by next monday.<br/><br/>Regards,<br/>Abhinav Singh";

    function eventMessage($fromJid, $content, $offline = FALSE) {

    }

    function eventPresence($fromJid, $status, $photo) {

    }

    function eventNewEMail($total,$thread,$url,$participation,$messages,$date,$senders,$labels,$subject,$snippet) {
      // We only want to send auto-reply message to latest sender
      $sender = $senders[0];

      // Check if the user lie in any category, and send appropriate mail
      if(in_array($sender["address"],$this->family)) {
        $mail = new PHPMailer();
        $mail->From = "youremailid@gmail.com";
        $mail->FromName = "Your Name";
        $mail->Subject = $this->familySubject;
        $mail->MsgHTML($this->familyMessage."<br/><br/>Powered by Jaxl http://code.google.com/p/jaxl");
        $mail->IsHTML(true);
        $mail->AddAddress($sender["address"],$sender["name"]);

        if(!$mail->Send()) $this->logger->logger("Error occured while sending mail to ".$sender["address"]);
        else $this->logger->logger("Mail sent successfully to ".$sender["address"]);
      }
      else if(in_array($sender["address"],$this->colleague)) {
        $mail = new PHPMailer();
        $mail->From = "youremailid@gmail.com";
        $mail->FromName = "Your Name";
        $mail->Subject = $this->colleagueSubject;
        $mail->MsgHTML($this->colleagueMessage."<br/><br/>Powered by Jaxl http://code.google.com/p/jaxl");
        $mail->IsHTML(true);
        $mail->AddAddress($sender["address"],$sender["name"]);

        if(!$mail->Send()) $this->logger->logger("Error occured while sending mail to ".$sender["address"]);
        else $this->logger->logger("Mail sent successfully to ".$sender["address"]);
      }
      else {
        // Do nothing, will handle later on
        $this->logger->logger("No handler for this email id...");
      }
    }

    function setStatus() {
      print "Setting Status...\n";
      $this->sendStatus("Available");
      print "Requesting new mails...\n";
      $this->getNewEMail();
      print "Done\n";
    }

  }
</pre>
<p>The only variables you would like to change in above class are:</p>
<ol>
<li><strong>$family</strong> : An array of email id of your family member</li>
<li><strong>$colleague</strong> : An array of email id of your colleagues</li>
<li><strong>$familySubject</strong> : Subject with which you want to send mails to your family members</li>
<li><strong>$familyMessage</strong> : Mail message which you want to send to you family</li>
<li><strong>$colleagueSubject</strong> : Subject with which you want to send mails to your colleagues</li>
<li><strong>$colleagueMessage</strong> : Mail message which you want to send to you colleagues</li>
</ol>
<p>For further customization, you may want to add more groups and their respective subjects and messages.</p>
<p>Further you may want to create your own custom bots using JAXL for one of the other use case described above. Join official <a href="http://groups.google.com/group/jaxl">JAXL Google Group</a> for future updates and enhancements.</p>
<p>Do let me know if you build any custom bot using JAXL, I will be more than happy to list your bot on <a href="http://code.google.com/p/jaxl">official JAXL google code</a> page.</p>
<p>Enjoy!</p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F02%2Fprogramatically-control-your-google-mails-using-jaxl-v-104%2F","http:\/\/code.google.com\/p\/jaxl","http:\/\/code.google.com\/apis\/talk\/jep_extensions\/gmail.html","http:\/\/en.wikipedia.org\/wiki\/Push_technology","http:\/\/code.google.com\/p\/jaxl\/source\/browse\/trunk\/jaxl4gmail.class.php","http:\/\/groups.google.com\/group\/jaxl","http:\/\/code.google.com\/p\/jaxl"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDA5LzAyL3Byb2dyYW1hdGljYWxseS1jb250cm9sLXlvdXItZ29vZ2xlLW1haWxzLXVzaW5nLWpheGwtdi0xMDQvPHdwdGI%2BUHJvZ3JhbWF0aWNhbGx5IGNvbnRyb2wgeW91ciBnb29nbGUgbWFpbHMgdXNpbmcgSkFYTCB2IDEuMC40PHdwdGI%2BaHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZzx3cHRiPkFiaGkmIzAzOTtzIFdlYmxvZw%3D%3D";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2009/05/how-to-broadcast-a-message-to-your-gtalk-friends-using-jaxl/" title="How to broadcast a message to your Gtalk friends using JAXL?">How to broadcast a message to your Gtalk friends using JAXL?</a> (13)</li><li><a href="http://abhinavsingh.com/blog/2009/01/introducing-jaxl-open-source-jabber-xmpp-library/" title="Introducing JAXL &#8211; Open Source Jabber XMPP Library">Introducing JAXL &#8211; Open Source Jabber XMPP Library</a> (92)</li><li><a href="http://abhinavsingh.com/blog/2010/08/releasing-jaxl-2-0-object-oriented-xmpp-framework-in-php/" title="Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP">Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP</a> (6)</li><li><a href="http://abhinavsingh.com/blog/2009/11/how-to-use-jaxl-jabber-xmpp-library-in-php-to-import-gtalk-contacts-of-any-user/" title="How to use JAXL (Jabber XMPP Library in PHP) to import Gtalk contacts of any user">How to use JAXL (Jabber XMPP Library in PHP) to import Gtalk contacts of any user</a> (40)</li><li><a href="http://abhinavsingh.com/blog/2009/01/how-to-get-dzone-feeds-as-im-using-jaxl-add-dzonegtalkbotscom/" title="How to get dzone feeds as IM using JAXL? Add dzone@gtalkbots.com">How to get dzone feeds as IM using JAXL? Add dzone@gtalkbots.com</a> (8)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2009/02/programatically-control-your-google-mails-using-jaxl-v-104/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

