<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Abhi's Weblog</title>
	
	<link>http://abhinavsingh.com/blog</link>
	<description>PHP, Memcached, XMPP and Web Development</description>
	<lastBuildDate>Mon, 27 Feb 2012 09:12:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/abhinavsingh" /><feedburner:info uri="abhinavsingh" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><creativeCommons:license>http://creativecommons.org/licenses/by/2.0/</creativeCommons:license><feedburner:emailServiceId>abhinavsingh</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>How to Write a Spelling Corrector in Erlang (ESpell)</title>
		<link>http://feedproxy.google.com/~r/abhinavsingh/~3/2sPBDito9iE/</link>
		<comments>http://abhinavsingh.com/blog/2012/02/how-to-write-a-spelling-corrector-in-erlang/#comments</comments>
		<pubDate>Mon, 27 Feb 2012 09:12:57 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[Erlang]]></category>
		<category><![CDATA[erlang]]></category>
		<category><![CDATA[listcomprehensions]]></category>
		<category><![CDATA[spellcorrector]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=1193</guid>
		<description><![CDATA[Erlang is a beautiful programming language from Ericsson which i first came across while cutomizing authentication flow of ejabberd about 2 years back. Ever since then I have been using erlang for all my application backend needs including custom http server, custom bosh conn. manager, xmpp components and clients, &#8230; Recently i have even started [...]]]></description>
			<content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/I6zADhSJVlNzjoaSroEmL0puKjc/0/da"><img src="http://feedads.g.doubleclick.net/~a/I6zADhSJVlNzjoaSroEmL0puKjc/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/I6zADhSJVlNzjoaSroEmL0puKjc/1/da"><img src="http://feedads.g.doubleclick.net/~a/I6zADhSJVlNzjoaSroEmL0puKjc/1/di" border="0" ismap="true"></img></a></p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2012%2F02%2Fhow-to-write-a-spelling-corrector-in-erlang%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2012%2F02%2Fhow-to-write-a-spelling-corrector-in-erlang%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=erlang,listcomprehensions,spellcorrector&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://www.erlang.org/">Erlang</a> is a beautiful programming language from Ericsson which i first came across while cutomizing authentication flow of <a href="https://github.com/processone/ejabberd">ejabberd</a> about 2 years back. Ever since then I have been using erlang for all my application backend needs including custom http server, custom bosh conn. manager, xmpp components and clients, &#8230; Recently i have even started churning my application html pages via erlang using <a href="http://code.google.com/p/erlydtl/">erlydtl</a> (an Erlang implementation of the Django Template Language).</p>
<p><a href="http://abhinavsingh.com/blog/2008/05/my-interview-with-yahoo-inc-part-1/">Years ago</a>, i gave a successful shot at implementing <a href="http://norvig.com/spell-correct.html">Peter Norvig&#8217;s Spell Corrector</a> in PHP. Last weekend i attempted the same &#8220;Spell Corrector&#8221; algorithm in about 45 lines of Erlang code.</p>
<p><strong style="font-size:16px;"><u>ESpell:</u></strong></p>
<p>Complete code file with comments and explaination can be found here:<br />
<a href="https://github.com/abhinavsingh/espell">https://github.com/abhinavsingh/espell</a></p>
<pre class="php" name="code">
-module(espell).
-define(alphabet, "abcdefghijklmnopqrstuvwxyz").
-export([start/0, correct/1]).

%%
%% API Functions
%%

%% @doc start spell checker
start() -> train(words()).

%% @doc returns most probable correct candidate with score
correct(Word) ->
	lists:foldl(
		fun(Candidate, {Correction, Score}) ->
			case ets:lookup(?MODULE, list_to_binary(Candidate)) of
				[{_, Counter}] when Counter > Score -> {Candidate, Counter};
				_ -> {Correction, Score}
			end
		end, {Word, 0}, get_candidates(Word)).

%%
%% Local Functions
%%

words() ->
	{ok, Bin} = file:read_file("../priv/big.txt"),
	{ok, Words} = regexp:split(binary_to_list(Bin), "[^a-zA-Z]"),
	lists:map(fun(X) -> string:to_lower(X) end, Words).

train(Features) ->
	io:fwrite("training initial word list...~n"),
	ets:new(?MODULE, [set, named_table]),
	lists:foreach(fun(X) ->
		case ets:insert_new(?MODULE, {list_to_binary(X), 1}) of
			false -> ets:update_counter(?MODULE, list_to_binary(X), 1);
			true -> true
		end
	end, Features),
	io:fwrite("training complete...~n"),
	ok.

edits1(Word) ->
	Splits = lists:foldl(fun(I, Acc) -> Acc ++ [{string:substr(Word, 1, I), string:substr(Word, I+1, string:len(Word)-I)}] end, [{"", Word}], lists:seq(1, string:len(Word))),
	Deletes = [A ++ string:substr(B, 2) || {A,B} <- Splits, B =/= []],
	Transposes = [A ++ string:substr(B, 2, 1) ++ string:substr(B, 1, 1) ++ string:substr(B, 3) || {A,B} <- Splits, string:len(B) > 1],
	Replaces = [A ++ binary_to_list(<<C:8>>) ++ string:substr(B, 2) || {A,B} <- Splits, B =/= [], C <- ?alphabet],
	Inserts = [A ++ binary_to_list(<<C:8>>) ++ B || {A,B} <- Splits, C <- ?alphabet],
	lists:usort(Deletes ++ Transposes ++ Replaces ++ Inserts).

%%edits2(Word) -> lists:usort([E2 || E1 <- edits1(Word), E2 <- edits1(E1)]).
known_edits2(Word) -> lists:usort([E2 || E1 <- edits1(Word), E2 <- edits1(E1), ets:member(?MODULE, list_to_binary(E2))]).
known(Words) -> lists:usort([Word || Word <- Words, ets:member(?MODULE, list_to_binary(Word))]).

get_candidates(Word) ->
	C1 = known([Word]),
	if
		length(C1) > 0 -> C1;
		true -> C2 = known(edits1(Word)),
			if
				length(C2) > 0 -> C2;
				true ->	C3 = known_edits2(Word),
					if length(C3) > 0 -> C3;
					true -> [Word] end
			end
	end.
</pre>
<p><strong style="font-size:16px;"><u>Try It Out:</u></strong><br />
espell provides 2 simple function for all it&#8217;s working:</p>
<ul>
<li>start() : start espell which initiates reading initial data and training phase</li>
<li>correct(Word) : this accepts 1 parameter, which is the word you want to correct. It returns a 2-tuple, where 1st element is the correct word and 2nd element is a score (which right now simply means number of times correct word was seen in training data set)</li>
</ul>
<pre class="php" name="code">
$ cd espell
$ erlc -o ebin/ src/espell.erl
$ erl -pa ebin/
Erlang R14B03 (erts-5.8.4) [source] [smp:4:4] [rq:4] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.8.4  (abort with ^G)
1> espell:start().
training initial word list...
training complete...
ok
2> espell:correct("speling").
{"spelling",4}
5> espell:correct("somthing").
{"something",683}
</pre>
<p>This code makes extensive use of <a href="http://www.erlang.org/doc/programming_examples/list_comprehensions.html">list comprehensions</a> in erlang, which is hugely responsible for cutting down espell code to just 45 lines of erlang.</p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2012%2F02%2Fhow-to-write-a-spelling-corrector-in-erlang%2F","http:\/\/www.erlang.org\/","https:\/\/github.com\/processone\/ejabberd","http:\/\/code.google.com\/p\/erlydtl\/","http:\/\/norvig.com\/spell-correct.html","https:\/\/github.com\/abhinavsingh\/espell","http:\/\/www.erlang.org\/doc\/programming_examples\/list_comprehensions.html"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDEyLzAyL2hvdy10by13cml0ZS1hLXNwZWxsaW5nLWNvcnJlY3Rvci1pbi1lcmxhbmcvPHdwdGI%2BSG93IHRvIFdyaXRlIGEgU3BlbGxpbmcgQ29ycmVjdG9yIGluIEVybGFuZyAoRVNwZWxsKTx3cHRiPmh0dHA6Ly9hYmhpbmF2c2luZ2guY29tL2Jsb2c8d3B0Yj5BYmhpJiMwMzk7cyBXZWJsb2c%3D";</script><h2  class="related_post_title">Most Commented Posts</h2><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2009/02/wordpress-toolbar-plugin/" title="Wordpress Toolbar Plugin">Wordpress Toolbar Plugin</a> (237)</li><li><a href="http://abhinavsingh.com/blog/2008/07/gain-admin-access-on-windows-system-using-your-guest-account/" title="Gain admin access on windows system using your guest account">Gain admin access on windows system using your guest account</a> (116)</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> (115)</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> (93)</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></ul><img src="http://feeds.feedburner.com/~r/abhinavsingh/~4/2sPBDito9iE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2012/02/how-to-write-a-spelling-corrector-in-erlang/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://abhinavsingh.com/blog/2012/02/how-to-write-a-spelling-corrector-in-erlang/</feedburner:origLink></item>
		<item>
		<title>JAXL library – List of available hooks for various XMPP events</title>
		<link>http://feedproxy.google.com/~r/abhinavsingh/~3/TMG9jJiUrqo/</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[
<p><a href="http://feedads.g.doubleclick.net/~a/BqpwgeRZ3cADpWJvnYWSJWJvmnU/0/da"><img src="http://feedads.g.doubleclick.net/~a/BqpwgeRZ3cADpWJvnYWSJWJvmnU/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/BqpwgeRZ3cADpWJvnYWSJWJvmnU/1/da"><img src="http://feedads.g.doubleclick.net/~a/BqpwgeRZ3cADpWJvnYWSJWJvmnU/1/di" border="0" ismap="true"></img></a></p><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> (115)</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> (1)</li></ul><img src="http://feeds.feedburner.com/~r/abhinavsingh/~4/TMG9jJiUrqo" height="1" width="1"/>]]></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>4</slash:comments>
		<feedburner:origLink>http://abhinavsingh.com/blog/2011/04/jaxl-library-list-of-available-hooks-for-various-xmpp-events/</feedburner:origLink></item>
		<item>
		<title>How to write External Jabber Components in PHP using Jaxl library?</title>
		<link>http://feedproxy.google.com/~r/abhinavsingh/~3/uc3x8d0MSws/</link>
		<comments>http://abhinavsingh.com/blog/2010/08/how-to-write-external-jabber-components-in-php-using-jaxl-library/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 11:58:39 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[XMPP]]></category>
		<category><![CDATA[Bots]]></category>
		<category><![CDATA[Component]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[JAXL]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=985</guid>
		<description><![CDATA[Jabber Component Protocol (XEP-0114) documents how XMPP protocol can be used to communicate between servers and &#8220;external&#8221; components over the Jabber network. XMPP components &#8220;bind&#8221; to a domain, usually a sub-domain of the main XMPP service, such as service.example.org. All incoming stanzas addressed to that domain (to='service.example.org') or to entities on that domain (to='user@service.example.org') will [...]]]></description>
			<content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/ws661qK3FZ4hMvIRSRMVat57iLw/0/da"><img src="http://feedads.g.doubleclick.net/~a/ws661qK3FZ4hMvIRSRMVat57iLw/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/ws661qK3FZ4hMvIRSRMVat57iLw/1/da"><img src="http://feedads.g.doubleclick.net/~a/ws661qK3FZ4hMvIRSRMVat57iLw/1/di" border="0" ismap="true"></img></a></p><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%2Fhow-to-write-external-jabber-components-in-php-using-jaxl-library%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F08%2Fhow-to-write-external-jabber-components-in-php-using-jaxl-library%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=Bots,Component,Documentation,JAXL&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Jabber Component Protocol (<a href="http://xmpp.org/extensions/xep-0114.html">XEP-0114</a>) documents how XMPP protocol can be used to communicate between servers and &#8220;external&#8221; components over the Jabber network. XMPP components &#8220;bind&#8221; to a domain, usually a sub-domain of the main XMPP service, such as <code>service.example.org</code>.</p>
<p>All incoming stanzas addressed to that domain (<code>to='service.example.org'</code>) or to entities on that domain (<code>to='user@service.example.org'</code>) will be routed to your Jaxl (Jabber XMPP Library) based code. In this blog post, I will demonstrate a sample external jabber component bot written in PHP using Jaxl library.</p>
<p>Refer <a href="http://abhinavsingh.com/blog/2010/08/jaxl-2-0-installation-usage-guide-and-example-apps/">Jaxl Installation, Usage guide and Example apps</a> if you are new to Jaxl. Demonstrated component bot code can be obtained from <a href="http://github.com/abhinavsingh/JAXL/tree/master/app/componentbot/">Jaxl@github</a>. </p>
<p><strong style="font-size:18px;"><u>Using Jabber Component Protocol</u></strong><br />
Include Jaxl implementation of XEP-0114 in your application code to setup necessary environment for using Jabber component protocol. Here is how this can be done at the top of your application code:
<pre class="php" name="code">        // Initialize Jaxl Library
        $jaxl = new JAXL(array(
                'component' => JAXL_COMPONENT_HOST,
                'port' => JAXL_COMPONENT_PORT
        ));

        // Include required XEP's
        jaxl_require('JAXL0114', $jaxl); // Jabber Component Protocol</pre>
<p><strong style="font-size:18px;"><u>Register callback for XMPP events</u></strong><br />
Above we have setup the necessary environment for writing external Jabber component bots. Next we register callback for necessary XMPP events inside our <code>componentbot</code> class.</p>
<pre class="php" name="code">
        // Sample Component class
        class componentbot {

        }

        // Add callbacks on various event handlers
        $componentbot = new componentbot();
        JAXLPlugin::add('jaxl_pre_handshake', array($componentbot, 'doAuth'));
        JAXLPlugin::add('jaxl_post_handshake', array($componentbot, 'postAuth'));
        JAXLPlugin::add('jaxl_get_message', array($componentbot, 'getMessage'));
</pre>
<p><strong style="font-size:18px;"><u>Component bot class</u></strong><br />
Finally, lets complete the missing pieces inside <code>componentbot</code> class.</p>
<pre class="php" name="code">
        // Sample Component class
        class componentbot {

                function doAuth() {
                        $jaxl->log("Going for component handshake ...", 1);
                        return JAXL_COMPONENT_PASS;
                }

                function postAuth() {
                        $jaxl->log("Component handshake completed ...", 1);
                }

                function getMessage($payloads) {
                        global $jaxl;

                        // echo back
                        foreach($payloads as $payload) {
                                $jaxl-&gt;sendMessage($payload['from'], $payload['body'], $payload['to']);
                        }
                }

        }
</pre>
<p><strong style="font-size:18px;"><u>Configure, Setup and Run</u></strong><br />
If you have a local &#8220;<a href="http://www.process-one.net/en/ejabberd/">ejabberd</a>&#8221; installed, add following lines inside <code>ejabberd.cfg</code> to make example component bot to work:
<pre class="php" name="code">  {5559, ejabberd_service, [
                          {host, "component.localhost", [{password, "pass"}]}
                           ]},</pre>
<p>Update <code>jaxl.ini</code> if you choose to have different password, port or host name above:
<pre class="php" name="code">        // Connecting jabber server details
        define('JAXL_HOST_NAME', 'localhost');
        define('JAXL_HOST_DOMAIN', 'localhost');

        // Component bot setting
        define('JAXL_COMPONENT_HOST', 'component.'.JAXL_HOST_DOMAIN);
        define('JAXL_COMPONENT_PASS', 'pass');
        define('JAXL_COMPONENT_PORT', 5559);</pre>
<p>Finally, run from command line:
<pre class="php" name="code">root@ubuntu:~/usr/share/php/jaxl/app/componentbot# jaxl componentbot.php
[15008] 2010-08-24 01:40:03 - Socket opened to the jabber host localhost:5559 ...</pre>
<p>Tail jaxl.log for details:
<pre class="php" name="code">[15008] 2010-08-24 01:40:04 - Going for component handshake ...

[15008] 2010-08-24 01:40:04 - [[XMPPSend]] 63
&lt;handshake&gt;4d6c2e762d5ba5dca2cbd3a90a4deeb6a6fa0838&lt;/handshake&gt;

[15008] 2010-08-24 01:40:05 - [[XMPPGet]]
&lt;handshake/&gt;

[15008] 2010-08-24 01:40:05 - Component handshake completed ...
</pre>
<p>Log into your Ejabberd with a client and send a message to anything@component.localhost &#8211; You should receive an instant response back &#8211; congratulations!</p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F08%2Fhow-to-write-external-jabber-components-in-php-using-jaxl-library%2F","http:\/\/xmpp.org\/extensions\/xep-0114.html","http:\/\/github.com\/abhinavsingh\/JAXL\/tree\/master\/app\/componentbot\/","http:\/\/www.process-one.net\/en\/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 = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDEwLzA4L2hvdy10by13cml0ZS1leHRlcm5hbC1qYWJiZXItY29tcG9uZW50cy1pbi1waHAtdXNpbmctamF4bC1saWJyYXJ5Lzx3cHRiPkhvdyB0byB3cml0ZSBFeHRlcm5hbCBKYWJiZXIgQ29tcG9uZW50cyBpbiBQSFAgdXNpbmcgSmF4bCBsaWJyYXJ5Pzx3cHRiPmh0dHA6Ly9hYmhpbmF2c2luZ2guY29tL2Jsb2c8d3B0Yj5BYmhpJiMwMzk7cyBXZWJsb2c%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> (4)</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/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/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> (115)</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> (1)</li></ul><img src="http://feeds.feedburner.com/~r/abhinavsingh/~4/uc3x8d0MSws" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2010/08/how-to-write-external-jabber-components-in-php-using-jaxl-library/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		<feedburner:origLink>http://abhinavsingh.com/blog/2010/08/how-to-write-external-jabber-components-in-php-using-jaxl-library/</feedburner:origLink></item>
		<item>
		<title>XEP 0045 – Multi User Chat (MUC) available methods in Jaxl 2.0</title>
		<link>http://feedproxy.google.com/~r/abhinavsingh/~3/ahPfg1PoPrw/</link>
		<comments>http://abhinavsingh.com/blog/2010/08/xep-0045-%e2%80%93-multi-user-chat-muc-available-methods-in-jaxl-2-0/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 14:09:47 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[XMPP]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[JAXL]]></category>
		<category><![CDATA[MUC]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=984</guid>
		<description><![CDATA[Jaxl 2.0.3 (Jabber XMPP Library in PHP) comes with 15 XMPP extensions including XEP-0045 a.k.a. Multi-User Chat (Conference Room). In this blog post, we will go through all the methods available for XMPP applications developed using Jaxl library. Using MUC methods You need to include Jaxl implementation of XEP-0045 in your application code to start [...]]]></description>
			<content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/FU_e_6tWpOVq8JLd75M1MgN6lWU/0/da"><img src="http://feedads.g.doubleclick.net/~a/FU_e_6tWpOVq8JLd75M1MgN6lWU/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/FU_e_6tWpOVq8JLd75M1MgN6lWU/1/da"><img src="http://feedads.g.doubleclick.net/~a/FU_e_6tWpOVq8JLd75M1MgN6lWU/1/di" border="0" ismap="true"></img></a></p><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%2Fxep-0045-%25e2%2580%2593-multi-user-chat-muc-available-methods-in-jaxl-2-0%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F08%2Fxep-0045-%25e2%2580%2593-multi-user-chat-muc-available-methods-in-jaxl-2-0%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=Documentation,JAXL,MUC&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Jaxl 2.0.3 (Jabber XMPP Library in PHP) comes with 15 XMPP extensions including XEP-0045 a.k.a. Multi-User Chat (Conference Room). In this blog post, we will go through all the methods available for XMPP applications developed using Jaxl library.</p>
<p><strong style="font-size:18px;"><u>Using MUC methods</u></strong><br />
You need to include Jaxl implementation of XEP-0045 in your application code to start using the methods listed below. Refer <a href="http://abhinavsingh.com/blog/2010/08/jaxl-2-0-installation-usage-guide-and-example-apps/">Jaxl Installation, Usage guide and Example apps</a> if you are new to Jaxl. Here is how this can be done at the top of your application code:
<pre class="php" name="code">// initialize Jaxl instance
$jaxl = new JAXL();

// include MUC XEP
jaxl_require('JAXL0045', $jaxl); // or simply $jaxl->requires('JAXL0045');</pre>
<p><strong style="font-size:18px;"><u>Multi-User Chat available methods:</u></strong><br />
Below is a detailed list of methods from multi-user room extension:</p>
<ul>
<li>$jaxl->JAXL0045(&#8216;joinRoom&#8217;, $jid, $roomJid.&#8221;/&#8221;.$nick, $history=0, $type=&#8217;seconds&#8217;)</li>
<li>$jaxl->JAXL0045(&#8216;exitRoom&#8217;, $jid, $roomJid)</li>
<li>$jaxl->JAXL0045(&#8216;kickOccupant&#8217;, $fromJid, $nick, $roomJid, $reason=FALSE, $callback=FALSE)</li>
<li>$jaxl->JAXL0045(&#8216;getRoomConfig&#8217;, $jid, $roomJid, $callback=FALSE)</li>
<li>$jaxl->JAXL0045(&#8216;setRoomConfig&#8217;, $jid, $roomJid, $fields, $callback=FALSE)</li>
<li>$jaxl->JAXL0045(&#8216;grantOwnerPrivileges&#8217;, $fromJid, $toJid, $roomJid, $reason=FALSE, $callback=FALSE)</li>
<li>$jaxl->JAXL0045(&#8216;revokeOwnerPrivileges&#8217;, $fromJid, $toJid, $roomJid, $reason=FALSE, $callback=FALSE)</li>
<li>$jaxl->JAXL0045(&#8216;grantAdminPrivileges&#8217;, $fromJid, $toJid, $roomJid, $reason=FALSE, $callback=FALSE)</li>
<li>$jaxl->JAXL0045(&#8216;removeAdminPrivileges&#8217;, $fromJid, $toJid, $roomJid, $reason=FALSE, $callback=FALSE)</li>
</ul>
<p>All parameters are mandatory to be passed while calling the above available methods. To be continued as more method gets added like <code>banUser</code>, <code>destroyRoom</code>, etc.</p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F08%2Fxep-0045-%25e2%2580%2593-multi-user-chat-muc-available-methods-in-jaxl-2-0%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 = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDEwLzA4L3hlcC0wMDQ1LSVlMiU4MCU5My1tdWx0aS11c2VyLWNoYXQtbXVjLWF2YWlsYWJsZS1tZXRob2RzLWluLWpheGwtMi0wLzx3cHRiPlhFUCAwMDQ1IOKAkyBNdWx0aSBVc2VyIENoYXQgKE1VQykgYXZhaWxhYmxlIG1ldGhvZHMgaW4gSmF4bCAyLjA8d3B0Yj5odHRwOi8vYWJoaW5hdnNpbmdoLmNvbS9ibG9nPHdwdGI%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> (4)</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/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/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> (115)</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> (1)</li></ul><img src="http://feeds.feedburner.com/~r/abhinavsingh/~4/ahPfg1PoPrw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2010/08/xep-0045-%e2%80%93-multi-user-chat-muc-available-methods-in-jaxl-2-0/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		<feedburner:origLink>http://abhinavsingh.com/blog/2010/08/xep-0045-%e2%80%93-multi-user-chat-muc-available-methods-in-jaxl-2-0/</feedburner:origLink></item>
		<item>
		<title>PHP Code, Setup and Demo of Jaxl boshchat application</title>
		<link>http://feedproxy.google.com/~r/abhinavsingh/~3/74_0NKHmJvg/</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[
<p><a href="http://feedads.g.doubleclick.net/~a/0Mx0fDh038nCmkniOR4IKYzu-kM/0/da"><img src="http://feedads.g.doubleclick.net/~a/0Mx0fDh038nCmkniOR4IKYzu-kM/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/0Mx0fDh038nCmkniOR4IKYzu-kM/1/da"><img src="http://feedads.g.doubleclick.net/~a/0Mx0fDh038nCmkniOR4IKYzu-kM/1/di" border="0" ismap="true"></img></a></p><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> (4)</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><img src="http://feeds.feedburner.com/~r/abhinavsingh/~4/74_0NKHmJvg" height="1" width="1"/>]]></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>
		<feedburner:origLink>http://abhinavsingh.com/blog/2010/08/php-code-setup-and-demo-of-jaxl-boshchat-application/</feedburner:origLink></item>
		<item>
		<title>Facebook chat connect with X-FACEBOOK-PLATFORM using Jaxl 2.0</title>
		<link>http://feedproxy.google.com/~r/abhinavsingh/~3/rpZ6bIy6rjg/</link>
		<comments>http://abhinavsingh.com/blog/2010/08/facebook-chat-connect-with-x-facebook-platform-using-jaxl-2-0/#comments</comments>
		<pubDate>Sun, 08 Aug 2010 12:42:32 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[XMPP]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Guide]]></category>
		<category><![CDATA[JAXL]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=913</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/naxXML46vEuaSZyf_24Ya5cv3jA/0/da"><img src="http://feedads.g.doubleclick.net/~a/naxXML46vEuaSZyf_24Ya5cv3jA/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/naxXML46vEuaSZyf_24Ya5cv3jA/1/da"><img src="http://feedads.g.doubleclick.net/~a/naxXML46vEuaSZyf_24Ya5cv3jA/1/di" border="0" ismap="true"></img></a></p><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%2Ffacebook-chat-connect-with-x-facebook-platform-using-jaxl-2-0%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F08%2Ffacebook-chat-connect-with-x-facebook-platform-using-jaxl-2-0%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=Documentation,Facebook,Guide,JAXL&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Facebook chat provides two authentication mechanisms for authenticating chat client users. <code>DIGEST-MD5</code> require chat client users to enter their username and password, while <code>X-FACEBOOK-PLATFORM</code> 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.</p>
<p><strong style="font-size:18px;"><u>Echobot using X-FACEBOOK-PLATFORM</u></strong><br />
<a href="http://abhinavsingh.com/blog/2010/08/jaxl-2-0-installation-usage-guide-and-example-apps/">Setup Jaxl library</a> on your system and edit packaged <a href="http://github.com/abhinavsingh/JAXL/tree/master/app/echobot/">sample echobot application</a> with facebook user account details. Alternately you can also specify connecting user details inside <code>jaxl.ini</code> configuration file.
<pre class="php" name="code">
        $jaxl = new JAXL(array(
                'user'=>'fbUsername',
                'pass'=>'', // Not required, we will use user session key instead
                'host'=>'chat.facebook.com',
                'domain'=>'chat.facebook.com'
        ));</pre>
<p>Add callback for hook <code>jaxl_get_facebook_key</code>:
<pre class="php" name="code">JAXLPlugin::add('jaxl_get_facebook_key', array($echobot, 'getFacebookKey'));</pre>
<p>Complete <code>getFacebookKey</code> method inside echobot application, which should return back following key information:
<pre class="php" name="code">function getFacebookKey() {
                        return array(
                                '', // Your application secret key
                                '', // Your application api key
                                '' // Connecting user session key
                        );
                }</pre>
<p>Update <code>doAuth</code> method to use <code>X-FACEBOOK-PLATFORM</code> auth mechanism:
<pre class="php" name="code">                function doAuth($mechanism) {
                        global $jaxl;
                        $jaxl->auth("X-FACEBOOK-PLATFORM");
                }</pre>
<p>Finally, run echobot from command line:</p>
<pre class="php" name="code">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...</pre>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F08%2Ffacebook-chat-connect-with-x-facebook-platform-using-jaxl-2-0%2F","http:\/\/github.com\/abhinavsingh\/JAXL\/tree\/master\/app\/echobot\/"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDEwLzA4L2ZhY2Vib29rLWNoYXQtY29ubmVjdC13aXRoLXgtZmFjZWJvb2stcGxhdGZvcm0tdXNpbmctamF4bC0yLTAvPHdwdGI%2BRmFjZWJvb2sgY2hhdCBjb25uZWN0IHdpdGggWC1GQUNFQk9PSy1QTEFURk9STSB1c2luZyBKYXhsIDIuMDx3cHRiPmh0dHA6Ly9hYmhpbmF2c2luZ2guY29tL2Jsb2c8d3B0Yj5BYmhpJiMwMzk7cyBXZWJsb2c%3D";</script><ul class="related_post"><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> (1)</li><li><a href="http://abhinavsingh.com/blog/2010/08/jaxl-2-0-core-classes-available-methods-and-directory-structure/" title="Jaxl 2.0 Core classes, available methods and directory structure">Jaxl 2.0 Core classes, available methods and directory structure</a> (3)</li><li><a href="http://abhinavsingh.com/blog/2010/08/writing-a-command-line-xmpp-bot-echobot-using-jaxl-2-0/" title="Writing a command line XMPP bot (echobot) using Jaxl 2.0">Writing a command line XMPP bot (echobot) using Jaxl 2.0</a> (35)</li><li><a href="http://abhinavsingh.com/blog/2010/08/jaxl-2-0-installation-usage-guide-and-example-apps/" title="Jaxl 2.0 &#8211; Installation, Usage guide and Example apps">Jaxl 2.0 &#8211; Installation, Usage guide and Example apps</a> (43)</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> (4)</li></ul><img src="http://feeds.feedburner.com/~r/abhinavsingh/~4/rpZ6bIy6rjg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2010/08/facebook-chat-connect-with-x-facebook-platform-using-jaxl-2-0/feed/</wfw:commentRss>
		<slash:comments>115</slash:comments>
		<feedburner:origLink>http://abhinavsingh.com/blog/2010/08/facebook-chat-connect-with-x-facebook-platform-using-jaxl-2-0/</feedburner:origLink></item>
		<item>
		<title>XEP 0133 – Service Administration available methods in Jaxl 2.0</title>
		<link>http://feedproxy.google.com/~r/abhinavsingh/~3/YzC3M_rWFd4/</link>
		<comments>http://abhinavsingh.com/blog/2010/08/xep-0133-service-administration-available-methods-in-jaxl-2-0/#comments</comments>
		<pubDate>Fri, 06 Aug 2010 12:06:20 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[XMPP]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[Guide]]></category>
		<category><![CDATA[JAXL]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=899</guid>
		<description><![CDATA[Jaxl 2.0 implements more than 10 XMPP extensions including XEP-0133 a.k.a. Service Administration. In this blog post, we will go through all the methods available for use in XMPP applications developed using Jaxl. Using Service administration methods You need to include Jaxl implementation of XEP-0133 in your application code to start using below listed available [...]]]></description>
			<content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/rzl8l2JWKU7SBmLSFGDWwdtMHeg/0/da"><img src="http://feedads.g.doubleclick.net/~a/rzl8l2JWKU7SBmLSFGDWwdtMHeg/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/rzl8l2JWKU7SBmLSFGDWwdtMHeg/1/da"><img src="http://feedads.g.doubleclick.net/~a/rzl8l2JWKU7SBmLSFGDWwdtMHeg/1/di" border="0" ismap="true"></img></a></p><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%2Fxep-0133-service-administration-available-methods-in-jaxl-2-0%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F08%2Fxep-0133-service-administration-available-methods-in-jaxl-2-0%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=Documentation,Guide,JAXL&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Jaxl 2.0 implements more than 10 XMPP extensions including XEP-0133 a.k.a. Service Administration. In this blog post, we will go through all the methods available for use in XMPP applications developed using Jaxl.</p>
<p><strong style="font-size:18px;"><u>Using Service administration methods</u></strong><br />
You need to include Jaxl implementation of XEP-0133 in your application code to start using below listed available methods. Here is how this can be done at the top of your application code:
<pre class="php" name="code">// initialize jaxl instance
$jaxl = new JAXL();

// include service administration
$jaxl->requires('JAXL0133'); // or jaxl_require('JAXL0133', $jaxl);</pre>
<p><strong style="font-size:18px;"><u>Service administration available methods</u></strong><br />
Below is a detailed list of methods from service administration extension:</p>
<ul>
<li>$jaxl->JAXL0133(&#8216;addUser&#8217;, $user, $domain, $callback)</li>
<li>$jaxl->JAXL0133(&#8216;deleteUser&#8217;, $user, $domain, $callback)</li>
<li>$jaxl->JAXL0133(&#8216;disableUser&#8217;, $user, $domain, $callback)</li>
<li>$jaxl->JAXL0133(&#8216;reEnableUser&#8217;, $user, $domain, $callback)</li>
<li>$jaxl->JAXL0133(&#8216;endUserSession&#8217;, $user, $domain, $callback)</li>
<li>$jaxl->JAXL0133(&#8216;getUserPassword&#8217;, $user, $domain, $callback)</li>
<li>$jaxl->JAXL0133(&#8216;changeUserPassword&#8217;, $user, $domain, $callback)</li>
<li>$jaxl->JAXL0133(&#8216;getUserRoster&#8217;, $user, $domain, $callback)</li>
<li>$jaxl->JAXL0133(&#8216;getUserLastLoginTime&#8217;, $user, $domain, $callback)</li>
<li>$jaxl->JAXL0133(&#8216;getUserStatistics&#8217;, $user, $domain, $callback)</li>
<li>$jaxl->JAXL0133(&#8216;editBlacklist&#8217;, $user, $domain, $callback)</li>
<li>$jaxl->JAXL0133(&#8216;editWhitelist&#8217;, $user, $domain, $callback)</li>
<li>$jaxl->JAXL0133(&#8216;getUserCount&#8217;, $user, $domain, $callback, $type)</li>
<li>$jaxl->JAXL0133(&#8216;getUserList&#8217;, $user, $domain, $callback, $type)</li>
<li>$jaxl->JAXL0133(&#8216;sendAnnouncementToActiveUsers&#8217;, $user, $domain, $callback)</li>
<li>$jaxl->JAXL0133(&#8216;setMOTD&#8217;, $user, $domain, $callback)</li>
<li>$jaxl->JAXL0133(&#8216;editMOTD&#8217;, $user, $domain, $callback)</li>
<li>$jaxl->JAXL0133(&#8216;deleteMOTD&#8217;, $user, $domain, $callback)</li>
<li>$jaxl->JAXL0133(&#8216;setWelcomeMessage&#8217;, $user, $domain, $callback)</li>
<li>$jaxl->JAXL0133(&#8216;deleteWelcomeMessage&#8217;, $user, $domain, $callback)</li>
<li>$jaxl->JAXL0133(&#8216;editAdminList&#8217;, $user, $domain, $callback)</li>
<li>$jaxl->JAXL0133(&#8216;restartService&#8217;, $user, $domain, $callback)</li>
<li>$jaxl->JAXL0133(&#8216;shutdownService&#8217;, $user, $domain, $callback)</li>
</ul>
<p><strong style="font-size:18px;"><u>Examples</u></strong><br />
All the methods expects 3 parameters as defined below:</p>
<ul>
<li><u>$user</u>: An associative array containing information about the user on whose account service administrative actions need to be taken</li>
<li><u>$domain</u>: Jabber domain to which $user belongs</li>
<li><u>$callback</u>: Specify where do you want to receive success/failure of executed service administration command</li>
<li><u>$type</u>: Required by <code>getUserCount</code> and <code>getUserList</code> methods. Allowed values are registered, disabled, online, active and idle.</li>
</ul>
<p>$user array MUST correspond to the fields in the request form for executing service administration commands. </p>
<p>Here is how to add a new user using XEP-0133:</p>
<pre class="php" name="code">$user = array(
        'jid' => 'newuser',
        'pass' => 'password',
        'email' => 'newuser@email.com',
        'fname' => 'Hello',
        'lname' => 'World'
);

$jaxl->JAXL0133('addUser', $user, 'jaxl.im', array($this, 'postAddUser'));</pre>
<p> Your application code must have a methods named &#8216;postAddUser&#8217; which will be called back by Jaxl core, when it finishes executing the command.</p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F08%2Fxep-0133-service-administration-available-methods-in-jaxl-2-0%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 = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDEwLzA4L3hlcC0wMTMzLXNlcnZpY2UtYWRtaW5pc3RyYXRpb24tYXZhaWxhYmxlLW1ldGhvZHMtaW4tamF4bC0yLTAvPHdwdGI%2BWEVQIDAxMzMgJiM4MjExOyBTZXJ2aWNlIEFkbWluaXN0cmF0aW9uIGF2YWlsYWJsZSBtZXRob2RzIGluIEpheGwgMi4wPHdwdGI%2BaHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZzx3cHRiPkFiaGkmIzAzOTtzIFdlYmxvZw%3D%3D";</script><ul class="related_post"><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> (115)</li><li><a href="http://abhinavsingh.com/blog/2010/08/jaxl-2-0-core-classes-available-methods-and-directory-structure/" title="Jaxl 2.0 Core classes, available methods and directory structure">Jaxl 2.0 Core classes, available methods and directory structure</a> (3)</li><li><a href="http://abhinavsingh.com/blog/2010/08/writing-a-command-line-xmpp-bot-echobot-using-jaxl-2-0/" title="Writing a command line XMPP bot (echobot) using Jaxl 2.0">Writing a command line XMPP bot (echobot) using Jaxl 2.0</a> (35)</li><li><a href="http://abhinavsingh.com/blog/2010/08/jaxl-2-0-installation-usage-guide-and-example-apps/" title="Jaxl 2.0 &#8211; Installation, Usage guide and Example apps">Jaxl 2.0 &#8211; Installation, Usage guide and Example apps</a> (43)</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> (4)</li></ul><img src="http://feeds.feedburner.com/~r/abhinavsingh/~4/YzC3M_rWFd4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2010/08/xep-0133-service-administration-available-methods-in-jaxl-2-0/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://abhinavsingh.com/blog/2010/08/xep-0133-service-administration-available-methods-in-jaxl-2-0/</feedburner:origLink></item>
		<item>
		<title>Jaxl 2.0 Core classes, available methods and directory structure</title>
		<link>http://feedproxy.google.com/~r/abhinavsingh/~3/oHmmrdSIP70/</link>
		<comments>http://abhinavsingh.com/blog/2010/08/jaxl-2-0-core-classes-available-methods-and-directory-structure/#comments</comments>
		<pubDate>Wed, 04 Aug 2010 11:30:50 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[XMPP]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[Guide]]></category>
		<category><![CDATA[JAXL]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=728</guid>
		<description><![CDATA[In this blog post we will dig deep into the core of Jaxl 2.0 &#8211; An XMPP framework written in PHP. Specifically, we will go through Jaxl core directory structure. Towards the end we will get familiar with various core classes and their available methods (e.g. $jaxl->sendMessage()), that developers can use in their XMPP applications. [...]]]></description>
			<content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/QqlxbitgkEZ_IdX7DMrj-YGxTwY/0/da"><img src="http://feedads.g.doubleclick.net/~a/QqlxbitgkEZ_IdX7DMrj-YGxTwY/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/QqlxbitgkEZ_IdX7DMrj-YGxTwY/1/da"><img src="http://feedads.g.doubleclick.net/~a/QqlxbitgkEZ_IdX7DMrj-YGxTwY/1/di" border="0" ismap="true"></img></a></p><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%2Fjaxl-2-0-core-classes-available-methods-and-directory-structure%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F08%2Fjaxl-2-0-core-classes-available-methods-and-directory-structure%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=Documentation,Guide,JAXL&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>In this blog post we will dig deep into the core of Jaxl 2.0 &#8211; An XMPP framework written in PHP. Specifically, we will go through Jaxl core directory structure. Towards the end we will get familiar with various core classes and their available methods (e.g. $jaxl->sendMessage()), that developers can use in their XMPP applications.</p>
<p><strong style="font-size:18px;"><u>Core Directory Structure</u></strong><br />
Now that you have the <a href="http://abhinavsingh.com/blog/2010/08/jaxl-2-0-installation-usage-guide-and-example-apps/">source code</a>, lets get familiar with the Jaxl directory structure. Downloaded source code consists of following 5 directories:</p>
<ul>
<li><strong><u>xmpp:</u></strong> Contain core stack which implements <a href="http://xmpp.org/rfcs/">XMPP rfc&#8217;s</a>. All files follow naming convention like xmpp.*.php</li>
<li><strong><u>core:</u></strong> Contains core stack which manages the library workflow. Also provides an xpath based XML parser, an event mechanism and various other utilities to the framework. All files follow naming convention like jaxl.*.php</li>
<li><strong><u>xep:</u></strong> Contains implemented XMPP extensions (<a href="http://xmpp.org/extensions/">XEP&#8217;s</a>). All files follow naming convention like jaxl.XEP-NUMBER.php</li>
<li><strong><u>env:</u></strong> Contains Jaxl main() file <strong>jaxl.php</strong>, Jaxl core configuration file <strong>jaxl.conf</strong> and application environment setup file <strong>jaxl.ini</strong>. For bosh application developers <strong>jaxl.js</strong> is a must include from this directory.</li>
<li><strong><u>app:</u></strong> Contains example applications which comes packed with Jaxl library</li>
</ul>
<p><strong style="font-size:18px;"><u>Core Classes and Available Methods</u></strong><br />
Below is a detailed list of all the core classes and available methods in developer land space:</p>
<p><strong style="font-size:14px;"><u>JAXL</u></strong><br />
This class is located inside <code>core/jaxl.class.php</code> and extends base XMPP class. Following is a list of methods available:</p>
<ul>
<li><u>__construct($config=array())</u> : Constructor accepts following configuration parameters. Passed parameters will overwrite corresponding jaxl.ini values:
<pre class="php" name="code">$config = array(
    'user'=>'', // JAXL_USER_NAME
    'pass'=>'', // JAXL_USER_PASS
    'host'=>'', // JAXL_HOST_NAME
    'port'=>'', // JAXL_HOST_PORT
    'domain'=>'', // JAXL_HOST_DOMAIN
    'component'=>'', // JAXL_COMPONENT_HOST
    'logPath'=>'', // JAXL_LOG_PATH
    'logRotate'=>'', // false or second in which to rotate log
    'logLevel'=>'', // JAXL_LOG_LEVEL
    'pidPath'=>'', // JAXL_PID_PATH
    'boshHost'=>'', // JAXL_BOSH_HOST
    'boshPort'=>'', // JAXL_BOSH_PORT
    'boshSuffix'=>'', // JAXL_BOSH_SUFFIX
    'resource'=>'', // connecting user resource identifier
    'streamTimeout'=>'', // connecting stream timeout
    'sigh'=>'', // boolean to forcible enable/disable sigh term
    'dumpStat'=>'', // false or numeric specifying second after which to dump stat
);</pre>
</li>
<li><u>auth($type)</u> : Performs authentication with the jabber server. DIGEST-MD5, PLAIN, <a href="http://abhinavsingh.com/blog/2010/08/facebook-chat-connect-with-x-facebook-platform-using-jaxl-2-0/">X-FACEBOOK-PLATFORM</a> and ANONYMOUS are the supported auth <code>$type</code></li>
<li><u>setStatus($status=FALSE, $show=FALSE, $priority=FALSE, $caps=FALSE)</u> : Update the status of connected jabber user. Pass <code>$caps=TRUE</code> for sending <a href="http://xmpp.org/extensions/xep-0115.html">entity capability</a> information while setting connected user status.</li>
<li><u>subscribe($toJid)</u></li>
<li><u>subscribed($toJid)</u></li>
<li><u>unsubscribe($toJid)</u></li>
<li><u>unsubscribed($toJid)</u></li>
<li><u>getRosterList($callback=FALSE)</u> : Fetch roster list for the connected user. See example usage inside <a href="http://github.com/abhinavsingh/JAXL/tree/master/app/echobot/">echobot</a> application.</li>
<li><u>addRoster($jid, $group, $name=FALSE)</u></li>
<li><u>updateRoster($jid, $group, $name=FALSE, $subscription=FALSE)</u></li>
<li><u>deleteRoster($jid)</u></li>
<li><u>sendMessage($to, $message, $from=FALSE, $type=&#8217;chat&#8217;)</u></li>
<li><u>sendMessages($to, $from, $child, $type)</u></li>
<li><u>sendPresence($to, $from, $child, $type)</u></li>
<li><u>$jaxl->requires($class)</u> : It is an alternative for jaxl_require($class, $jaxl).</li>
<li><u>$jaxl->xml->xmlize($xml)</u> : Use this method to convert raw XML string into an array.</li>
<li><u>$jaxl->log($log, $level)</u> : Use this method for logging purposes</li>
</ul>
<p><strong style="font-size:14px;"><u>JAXLPlugin</u></strong><br />
This class is located inside <code>core/jaxl.plugin.php</code>. Following is a list of methods available:</p>
<ul>
<li><u>add($hook, $callback, $priority=10)</u> : Register callback on available hooks</li>
<li><u>remove($hook, $callback)</u> : Un-register callback on a previously registered hooks using <code>add</code> method</li>
</ul>
<p><strong style="font-size:14px;"><u>JAXLCron</u></strong><br />
This class is located inside <code>core/jaxl.cron.php</code>. Use this call methods to run periodic background jobs. Following is a list of methods available:</p>
<ul>
<li><u>add($callback, $interval)</u> : $callback methods is called every $interval second</li>
<li><u>delete($callback, $interval)</u> : Removes a previously registered cron job</li>
</ul>
<p><strong style="font-size:14px;"><u>JAXLUtil</u></strong><br />
This class is located inside <code>core/jaxl.util.php</code>. Following is a list of methods available:</p>
<ul>
<li><u>isWin()</u> : Window OS detection, return bool</li>
<li><u>getTime()</u></li>
<li><u>getBareJid($jid)</u></li>
<li><u>splitJid($jid)</u></li>
<li><u>curl($url, $type=&#8217;GET&#8217;, $headers=FALSE, $data=FALSE, $user=FALSE, $pass=FALSE)</u></li>
</ul>
<p>More methods might get added in future and will be updated here.</p>
<p><strong style="font-size:18px;"><u>Using available XEP methods</u></strong><br />
Once have included required XEP class inside your application code, either by using <code>jaxl_require('JAXLxxxx', $jaxl)</code> or by calling <code>$jaxl->requires('JAXLxxxx')</code>, you can start using the available methods inside included XEP class as follows:</p>
<pre class="php" name="code">$jaxl->JAXLxxxx('methodName', $param1, $param2, ....);</pre>
<p> e.g. If you want to call joinRoom methods of Multi-User Chat XEP-0045, you can do so by calling
<pre class="php" name="code">$jaxl->JAXL0045('joinRoom', $jid, $roomJid.'/'.$nick, $history, $seconds)</pre>
<p>. DO-NOT call the method like <del datetime="2010-08-30T16:04:20+00:00">JAXL0045::joinRoom(&#8230;)</del></p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F08%2Fjaxl-2-0-core-classes-available-methods-and-directory-structure%2F","http:\/\/xmpp.org\/rfcs\/","http:\/\/xmpp.org\/extensions\/","http:\/\/xmpp.org\/extensions\/xep-0115.html","http:\/\/github.com\/abhinavsingh\/JAXL\/tree\/master\/app\/echobot\/"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDEwLzA4L2pheGwtMi0wLWNvcmUtY2xhc3Nlcy1hdmFpbGFibGUtbWV0aG9kcy1hbmQtZGlyZWN0b3J5LXN0cnVjdHVyZS88d3B0Yj5KYXhsIDIuMCBDb3JlIGNsYXNzZXMsIGF2YWlsYWJsZSBtZXRob2RzIGFuZCBkaXJlY3Rvcnkgc3RydWN0dXJlPHdwdGI%2BaHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZzx3cHRiPkFiaGkmIzAzOTtzIFdlYmxvZw%3D%3D";</script><ul class="related_post"><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> (115)</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> (1)</li><li><a href="http://abhinavsingh.com/blog/2010/08/writing-a-command-line-xmpp-bot-echobot-using-jaxl-2-0/" title="Writing a command line XMPP bot (echobot) using Jaxl 2.0">Writing a command line XMPP bot (echobot) using Jaxl 2.0</a> (35)</li><li><a href="http://abhinavsingh.com/blog/2010/08/jaxl-2-0-installation-usage-guide-and-example-apps/" title="Jaxl 2.0 &#8211; Installation, Usage guide and Example apps">Jaxl 2.0 &#8211; Installation, Usage guide and Example apps</a> (43)</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> (4)</li></ul><img src="http://feeds.feedburner.com/~r/abhinavsingh/~4/oHmmrdSIP70" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2010/08/jaxl-2-0-core-classes-available-methods-and-directory-structure/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://abhinavsingh.com/blog/2010/08/jaxl-2-0-core-classes-available-methods-and-directory-structure/</feedburner:origLink></item>
		<item>
		<title>Writing a command line XMPP bot (echobot) using Jaxl 2.0</title>
		<link>http://feedproxy.google.com/~r/abhinavsingh/~3/UCEFMKmGsVw/</link>
		<comments>http://abhinavsingh.com/blog/2010/08/writing-a-command-line-xmpp-bot-echobot-using-jaxl-2-0/#comments</comments>
		<pubDate>Tue, 03 Aug 2010 12:44:36 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[XMPP]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[Guide]]></category>
		<category><![CDATA[JAXL]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=675</guid>
		<description><![CDATA[In this blog post, we will write a sample XMPP bot (echobot) using Jaxl 2.0. In turn we will introduce ourselves to some of the basic functionality we can do using Jaxl e.g. fetching roster list, subscribing and unsubscribing to a user presence, etc. We will also focus on how to use XMPP extensions (XEP&#8217;s) [...]]]></description>
			<content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/99q9vCAMnqLlaD-wncb5IWFmClA/0/da"><img src="http://feedads.g.doubleclick.net/~a/99q9vCAMnqLlaD-wncb5IWFmClA/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/99q9vCAMnqLlaD-wncb5IWFmClA/1/da"><img src="http://feedads.g.doubleclick.net/~a/99q9vCAMnqLlaD-wncb5IWFmClA/1/di" border="0" ismap="true"></img></a></p><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%2Fwriting-a-command-line-xmpp-bot-echobot-using-jaxl-2-0%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F08%2Fwriting-a-command-line-xmpp-bot-echobot-using-jaxl-2-0%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=Documentation,Guide,JAXL&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>In this blog post, we will write a sample XMPP bot (echobot) using Jaxl 2.0. In turn we will introduce ourselves to some of the basic functionality we can do using Jaxl e.g. fetching roster list, subscribing and unsubscribing to a user presence, etc. We will also focus on how to use XMPP extensions (XEP&#8217;s) inside our echobot code. Specifically, we will make use of XEP-0085 (chat state notification), XEP-0203 (delayed delivery) and XEP-0092 (software version) in our sample echobot application.</p>
<p><strong style="font-size:18px;"><u>Echobot source code:</u></strong><br />
This sample echobot application comes packaged with Jaxl 2.0. If you have already read <a href="http://abhinavsingh.com/blog/2010/08/jaxl-2-0-installation-usage-guide-and-example-apps/">Installation, Usage guide and Running example apps</a>, you might have even run this sample application.</p>
<p>Alternately, browse and download the sample source code from github <a href="http://github.com/abhinavsingh/JAXL/tree/master/app/echobot/">echobot app files</a></p>
<p><strong style="font-size:18px;"><u>Coding with Jaxl 2.0:</u></strong><br />
Every XMPP application developed using Jaxl 2.0, MUST have a <code>jaxl.ini</code> environment setup file inside your project directory. For example, packaged echobot sample application contains <a href="http://github.com/abhinavsingh/JAXL/tree/master/app/echobot/">jaxl.ini</a> which setup necessary Jaxl environment for our echobot application.</p>
<p>If you are developing an application from scratch, copy sample packaged <code>jaxl.ini</code> into your project folder:
<pre name="code" class="php">cp /usr/share/php/jaxl/env/jaxl.ini /my/app/directory/jaxl.ini</pre>
<p> and update <code>JAXL_BASE_PATH</code> and <code>JAXL_APP_BASE_PATH</code> with Jaxl installation path and your application directory path respectively.</p>
<p>Before we go on to write our echobot application code logic, lets see how an XMPP application code written using Jaxl 2.0 will generally look like:</p>
<pre class="php" name="code">&lt;?php

        // Initialize Jaxl Library (#1)
        $jaxl = new JAXL();

        // Include required XEP's (#2)
        jaxl_require(array(
                'JAXL0085', // Chat State Notification
                'JAXL0092', // Software Version
                'JAXL0203'  // Delayed Delivery
        ), $jaxl);

        // Sample Echobot class (#3)
        class echobot {
                function startStream() {}
                function doAuth($mechanism) {}
                function postAuth() {}
                function getMessage($payloads) {}
                function getPresence($payloads) {}
        }
        $echobot = new echobot();

        // Add callbacks on various xmpp events (#4)
        JAXLPlugin::add('jaxl_post_connect', array($echobot, 'startStream'));
        JAXLPlugin::add('jaxl_get_auth_mech', array($echobot, 'doAuth'));
        JAXLPlugin::add('jaxl_post_auth', array($echobot, 'postAuth'));
        JAXLPlugin::add('jaxl_get_message', array($echobot, 'getMessage'));
        JAXLPlugin::add('jaxl_get_presence', array($echobot, 'getPresence'));

?&gt;</pre>
<p>Lets break down the above applications code structure (note the #1, #2, #3, #4 markers in the above code)</p>
<ul>
<li><strong>#1</strong> &#8211; Create a new Jaxl instance inside your application. By doing so Jaxl core functionality and other utilities are made available inside your application code. You can also pass parameters while initializing Jaxl instance
<pre class="php" name="code">$jaxl = new JAXL(array(
        'user'    =>    'username',
        'pass'    =>    'password',
        'host'    =>    'talk.google.com',
        'domain' =>    'gmail.com',
        'port'    =>    5222
));</pre>
<p>Passed parameters will overwrite the values specified inside <code>jaxl.ini</code> file</li>
<li><strong>#2</strong> &#8211; Include required XMPP extensions (XEP&#8217;s) inside your application code. <strong>jaxl_require</strong> is a special method which makes sure that no Jaxl core class loads twice inside a running Jaxl instance.<br/><br/>To include an implemented XEP inside your application code simply use:
<pre class="php" name="code">jaxl_require('JAXL0203', $jaxl);</pre>
<p> where 0203 is the XEP number</a> for <em><a href="http://xmpp.org/extensions/xep-0203.html">Delayed Delivery</a></em> extension, which will help our echobot know if an incoming message is an offline message. If you wish to include more than one XEP inside your application code, simply pass the list of XEP&#8217;s as an array:
<pre class="php" name="code">jaxl_require(array(
	'JAXL0085',
	'JAXL0092',
	'JAXL0203'
), $jaxl);</pre>
<p> where 0085 is xep number for <em><a href="http://xmpp.org/extensions/xep-0085.html">Chat state notification</a></em> extension and 0092 is the xep number for <em><a href="http://xmpp.org/extensions/xep-0092.html">Software Version</a></em> extension.<br/><br/>Since version 2.1.0, <code>jaxl_require</code> MANDOTORY accepts Jaxl instance which require core classes, in this case <code>$jaxl</code>. It helps Jaxl core to keep a track of required core classes for every Jaxl instances in a multiple-instance application.</li>
<li><strong>#3</strong> &#8211; Now that we have Jaxl core and required XEP&#8217;s in our application environment, it&#8217;s time to write our application code logic. Application code MUST have methods which are called back by the Jaxl core when specific xmpp events occur during your application run time. Optionally, Jaxl core can pass parameters to these methods during callbacks.</li>
<li><strong>#4</strong> &#8211; In the final step, we will register callbacks for necessary xmpp events using <code>JAXLPlugin</code> class <code>add()</code> method inside our application logic. Syntax:
<pre class="php" name="code">JAXLPlugin::add($hook, $callback);</pre>
<p> In this example, we want to receive callbacks in our application code for following available hooks and events:</p>
<ol>
<li><u>jaxl_post_connect:</u> After Jaxl has opened stream socket to the jabber server</li>
<li><u>jaxl_get_auth_mech:</u> When Jaxl have information about supported auth mechanisms by the jabber server</li>
<li><u>jaxl_post_auth:</u> After Jaxl finish authenticating the bot with the jabber server</li>
<li><u>jaxl_get_message:</u> When a new message stanza is received by Jaxl</li>
<li><u>jaxl_get_presence:</u> When a new presence stanza is received by Jaxl</li>
</ol>
</li>
</ul>
<p><strong style="font-size:18px;"><u>Writing application logic:</u></strong><br />
Till now we have the registered callbacks for various xmpp events, it&#8217;s time to catch these callbacks inside our echobot class and implement the required functionality of our application. Below is an explanation for some of the important pieces inside echobot class:</p>
<ul>
<li><em>startStream()</em> method is called when <code>jaxl_post_connect</code> event occurs. For our application we will simply send XMPP start stream by calling <code>$jaxl->startStream()</code></li>
<li><em>doAuth($mechanism)</em> method is called when <code>jaxl_get_auth_mech</code> event occurs in Jaxl core. Jaxl core passes list of supported auth mechanism by the jabber server. Proceed with a preferred auth type by calling <code>$jaxl->auth()</code> method</li>
<li><em>postAuth()</em> is called after Jaxl library has finished authenticating our application bot with the jabber server</li>
<li><em>getMessage($payloads)</em> gets all new messages as they are received by Jaxl core</li>
<li>getPresence($payloads) gets all new presence as they are received by Jaxl core</li>
</ul>
<p> <strong style="font-size:18px;"><u>Running Echobot:</u></strong><br />
Enter your application directory (<code>/usr/share/php/jaxl/echobot</code>). It MUST contain <code>jaxl.ini</code>, open and edit connecting echobot username, password and jabber host. Then from command line run echobot as follows:</p>
<pre class="php" name="code">root@ubuntu:/usr/share/pear/jaxl/app/echobot# jaxl echobot.php
== 5617 == [[2010-08-03 10:37:21]] Socket opened to the jabber host jaxl.im:5222 ...
== 5617 == [[2010-08-03 10:37:22]] Performing Auth type: DIGEST-MD5
== 5617 == [[2010-08-03 10:37:28]] Auth completed...</pre>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F08%2Fwriting-a-command-line-xmpp-bot-echobot-using-jaxl-2-0%2F","http:\/\/github.com\/abhinavsingh\/JAXL\/tree\/master\/app\/echobot\/","http:\/\/github.com\/abhinavsingh\/JAXL\/tree\/master\/app\/echobot\/","http:\/\/xmpp.org\/extensions\/xep-0203.html","http:\/\/xmpp.org\/extensions\/xep-0085.html","http:\/\/xmpp.org\/extensions\/xep-0092.html"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDEwLzA4L3dyaXRpbmctYS1jb21tYW5kLWxpbmUteG1wcC1ib3QtZWNob2JvdC11c2luZy1qYXhsLTItMC88d3B0Yj5Xcml0aW5nIGEgY29tbWFuZCBsaW5lIFhNUFAgYm90IChlY2hvYm90KSB1c2luZyBKYXhsIDIuMDx3cHRiPmh0dHA6Ly9hYmhpbmF2c2luZ2guY29tL2Jsb2c8d3B0Yj5BYmhpJiMwMzk7cyBXZWJsb2c%3D";</script><ul class="related_post"><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> (115)</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> (1)</li><li><a href="http://abhinavsingh.com/blog/2010/08/jaxl-2-0-core-classes-available-methods-and-directory-structure/" title="Jaxl 2.0 Core classes, available methods and directory structure">Jaxl 2.0 Core classes, available methods and directory structure</a> (3)</li><li><a href="http://abhinavsingh.com/blog/2010/08/jaxl-2-0-installation-usage-guide-and-example-apps/" title="Jaxl 2.0 &#8211; Installation, Usage guide and Example apps">Jaxl 2.0 &#8211; Installation, Usage guide and Example apps</a> (43)</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> (4)</li></ul><img src="http://feeds.feedburner.com/~r/abhinavsingh/~4/UCEFMKmGsVw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2010/08/writing-a-command-line-xmpp-bot-echobot-using-jaxl-2-0/feed/</wfw:commentRss>
		<slash:comments>35</slash:comments>
		<feedburner:origLink>http://abhinavsingh.com/blog/2010/08/writing-a-command-line-xmpp-bot-echobot-using-jaxl-2-0/</feedburner:origLink></item>
		<item>
		<title>Jaxl 2.0 – Installation, Usage guide and Example apps</title>
		<link>http://feedproxy.google.com/~r/abhinavsingh/~3/L8jwuduL_FQ/</link>
		<comments>http://abhinavsingh.com/blog/2010/08/jaxl-2-0-installation-usage-guide-and-example-apps/#comments</comments>
		<pubDate>Mon, 02 Aug 2010 22:41:32 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[XMPP]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[Guide]]></category>
		<category><![CDATA[JAXL]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=673</guid>
		<description><![CDATA[This blog post provides detailed instructions on how to download and setup Jaxl 2.0 for quick XMPP application development using PHP. We will also see how to run XMPP bots using Jaxl command line utility (now available by just typing jaxl on the terminal). Get the source code Jaxl 2.0 development version source code is [...]]]></description>
			<content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/IghT7x6YBXm1PwZTsurcy2Zz2sA/0/da"><img src="http://feedads.g.doubleclick.net/~a/IghT7x6YBXm1PwZTsurcy2Zz2sA/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/IghT7x6YBXm1PwZTsurcy2Zz2sA/1/da"><img src="http://feedads.g.doubleclick.net/~a/IghT7x6YBXm1PwZTsurcy2Zz2sA/1/di" border="0" ismap="true"></img></a></p><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%2Fjaxl-2-0-installation-usage-guide-and-example-apps%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F08%2Fjaxl-2-0-installation-usage-guide-and-example-apps%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=Documentation,Guide,JAXL&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>This blog post provides detailed instructions on how to download and setup Jaxl 2.0 for quick XMPP application development using PHP. We will also see how to run XMPP bots using Jaxl command line utility (now available by just typing <strong>jaxl</strong> on the terminal).</p>
<p><strong style="font-size:18px;"><u>Get the source code</u></strong><br />
Jaxl 2.0 development version source code is available at <a href="http://github.com/abhinavsingh/JAXL">github</a>.</p>
<ul>
<li>For better experience download <a href="http://code.google.com/p/jaxl/downloads/list">latest stable tarball</a> from google code</li>
<li>The development version of Jaxl is <a href="http://github.com/abhinavsingh/JAXL">hosted here at Github</a>, have fun cloning the source code with Git. If you are not familar with Git just use the <strong>download</strong> button to get a tarball.
<pre class="php" name="code">root@ubuntu:~/git# git clone git://github.com/abhinavsingh/JAXL.git</pre>
</li>
</ul>
<p><strong>Warning:</strong> the development source code is only intended for people that want to develop Jaxl or absolutely need the latest features still not available on the stable releases.</p>
<p><strong style="font-size:18px;"><u>Installation on *nix Systems</u></strong><br />
Extract the downloaded tarball and enter source directory. The available <code>build.sh</code> file will help us installing Jaxl library at a preferred location on our system. Type <code>./build.sh help</code> to view help instructions:</p>
<pre class="php" name="code">root@ubuntu:~/git# cd JAXL
root@ubuntu:~/git/JAXL# ./build.sh help</pre>
<p>Build file will default install Jaxl library core under <code>/usr/share/php/jaxl</code> and Jaxl command line at <code>/usr/bin/jaxl</code>. Open build script, edit <code>PACKAGE_INSTALL_PATH</code> and <code>PACKAGE_BIN_PATH</code> to configure installation paths.</p>
<p>Issue following commands to setup Jaxl library core and Jaxl command line utility:</p>
<pre class="php" name="code">root@ubuntu:~/git/JAXL# mkdir /usr/share/php/jaxl
root@ubuntu:~/git/JAXL# ./build.sh
building...
root@ubuntu:~/git/JAXL# ./build.sh install
uninstalling old package...
installing...
root@ubuntu:~/git/JAXL# touch /var/log/jaxl.log
root@ubuntu:~/git/JAXL# chown www-data /var/log/jaxl.log
root@ubuntu:~/git/JAXL# touch /var/run/jaxl.pid
root@ubuntu:~/git/JAXL# chown www-data /var/run/jaxl.pid</pre>
<p><code>/var/log/jaxl.log</code> is default log file for Jaxl applications and <code>/var/run/jaxl.pid</code> saves the process id (pid) of running Jaxl instances.</p>
<p><strong style="font-size:18px;"><u>Usage guide</u></strong><br />
Now that we have setup Jaxl on our system, lets verify package installation by firing jaxl command line utility on the terminal:</p>
<pre class="php" name="code">root@ubuntu:~/git/JAXL# jaxl
Missing ini file...</pre>
<p>If you get <em>&#8220;Missing ini file&#8221;</em> message, you have successfully verified package installation. This message is shown when current working directory doesn&#8217;t have <code>jaxl.ini</code> file, which is required by Jaxl cli utility before it can connects to a jabber server.</p>
<p><strong style="font-size:18px;"><u>Running sample applications</u></strong><br />
Build script installs a sample application under <code>/usr/share/php/jaxl/app/echobot</code> directory. This directory contains two files namely:</p>
<ul>
<li><u>echobot.php:</u> Contains our echobot application code</li>
<li><u>jaxl.ini:</u> It is application specific Jaxl configuration file</li>
</ul>
<p>Open and update the following section inside jaxl.ini:</p>
<pre class="php" name="code">        // Connecting bot details
        define('JAXL_USER_NAME', 'username');
        define('JAXL_USER_PASS', 'password');

        // Connecting jabber server details
        define('JAXL_HOST_NAME', 'jabber.org');
        define('JAXL_HOST_PORT', 5222);
        define('JAXL_HOST_DOMAIN', 'jabber.org');</pre>
<p>Now run the echobot from using jaxl cli utility:</p>
<pre class="php" name="code">root@ubuntu:/usr/share/php/jaxl/app/echobot# jaxl echobot.php
== 2946 == [[2010-08-02 14:37:53]] Socket opened to the jabber host jabber.org:5222 ...
== 2946 == [[2010-08-02 14:37:57]] Performing Auth type: DIGEST-MD5
== 2946 == [[2010-08-02 14:38:02]] Auth completed...</pre>
<p><code>2946</code> is the process id of current running Jaxl instance. Same value can be found inside <code>/var/run/jaxl.pid</code>. Also tail the Jaxl log file for debug information:</p>
<pre class="php" name="code">root@ubuntu:~/git/JAXL# tail -f /var/log/jaxl.log
== 2946 == [[2010-08-02 14:38:02]] [[XMPPSend]] 123
<presence><show>chat</show><status>Online using Jaxl (Jabber XMPP Library in PHP)</status>
<priority>1</priority></presence></pre>
<p><code>[[XMPPSend]]</code> tells us that following XMPP packet was send by the Jaxl instance running with pid <code>2946</code>. Also, total <code>123</code> bytes were transmitted over the socket.</p>
<p>Proceed to <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> for detailed explanation of the sample echobot application or if you are interested in building real-time web applications read <a href="http://abhinavsingh.com/blog/2010/08/php-code-setup-and-demo-of-jaxl-boshchat-application/">Setup and Demo of Jaxl boshchat application</a></p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F08%2Fjaxl-2-0-installation-usage-guide-and-example-apps%2F","http:\/\/github.com\/abhinavsingh\/JAXL","http:\/\/code.google.com\/p\/jaxl\/downloads\/list","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 = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDEwLzA4L2pheGwtMi0wLWluc3RhbGxhdGlvbi11c2FnZS1ndWlkZS1hbmQtZXhhbXBsZS1hcHBzLzx3cHRiPkpheGwgMi4wICYjODIxMTsgSW5zdGFsbGF0aW9uLCBVc2FnZSBndWlkZSBhbmQgRXhhbXBsZSBhcHBzPHdwdGI%2BaHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZzx3cHRiPkFiaGkmIzAzOTtzIFdlYmxvZw%3D%3D";</script><ul class="related_post"><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> (115)</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> (1)</li><li><a href="http://abhinavsingh.com/blog/2010/08/jaxl-2-0-core-classes-available-methods-and-directory-structure/" title="Jaxl 2.0 Core classes, available methods and directory structure">Jaxl 2.0 Core classes, available methods and directory structure</a> (3)</li><li><a href="http://abhinavsingh.com/blog/2010/08/writing-a-command-line-xmpp-bot-echobot-using-jaxl-2-0/" title="Writing a command line XMPP bot (echobot) using Jaxl 2.0">Writing a command line XMPP bot (echobot) using Jaxl 2.0</a> (35)</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> (4)</li></ul><img src="http://feeds.feedburner.com/~r/abhinavsingh/~4/L8jwuduL_FQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2010/08/jaxl-2-0-installation-usage-guide-and-example-apps/feed/</wfw:commentRss>
		<slash:comments>43</slash:comments>
		<feedburner:origLink>http://abhinavsingh.com/blog/2010/08/jaxl-2-0-installation-usage-guide-and-example-apps/</feedburner:origLink></item>
	</channel>
</rss>

