Back to blogging: What to expect

Hello Readers, I started this blog as a way to share my experiments and experiences while learning web development and computer science in general. In the first 2 years (between Apr’08 and Aug’10) I wrote as many as 100 blog posts. Quite a frenzy. Ever since, I only managed to write 5-6 posts in the following 4 years, about nearly 45 drafts which may now never get published. Good thing is that, I am back to blogging, which means a lot to share. Briefly, here is what (or what not) to expect in the future posts: PHP – In past, PHP has dominated the content on this blog. Mostly web demos, some quick hacks or some JAXL library examples. However, I am no longer working actively with PHP since ’10 and probably never saw it after ’12. Expect zero PHP. JAXL – No more PHP essentially means no […]

Read More

How to perform X-FACEBOOK-PLATFORM and Google Talk X-OAUTH2 XMPP authentication with PHP Jaxl library

Ever since Jaxl library first introduced support for X-FACEBOOK-PLATFORM XMPP authentication mechanism, it has changed significantly. Also, Google Talk now supports OAuth 2.0 Authorization, an XMPP extension to allow users to log in using OAuth 2.0 credentials. Both these mechanisms are a big win for XMPP developers, since real-time conversation experience can now be provided to their application users without asking them for their passwords. In this blog post, I will demonstrate how to perform X-FACEBOOK-PLATFORM and X-OAUTH2 XMPP authentication mechanism using Jaxl v3.x PHP Library. X-FACEBOOK-PLATFORM XMPP Authentication Here is a quick guide on how to perform X-FACEBOOK-PLATFORM XMPP authentication using xfacebook_platform_client.php which comes bundled with Jaxl v3.x examples: Visit Facebook Developer Apps page and register your application Once registered, visit access token tool to get required parameters to perform X-FACEBOOK-PLATFORM authentication Click on the debug button next to […]

Read More

JAXLXml – Strophe style XML Builder : Working with Jaxl – A Networking Library in PHP – Part 2

Prior to Jaxl v3.x, the most ugliest piece of code inside Jaxl library was handling of XML packets. If you are working with XMPP protocol which is all about sending and receiving XML packets, it can become a nightmare if you don’t have a proper XML manipulation library in your toolkit. For Jaxl v3.x, first thing I decided to write was JAXLXml class, which is a custom XML packet implementation with no external dependencies and is an extension over the ideas from Strophe.Builder class written by Jack Moffitt. JAXLXml is generic enough to find a place inside any PHP application that requires easy and elegant XML packet creation. In this blog post, I will give an exhaustive overview of how to create XML packets using JAXLXml class. JAXLXml Constructor Depending upon the need, there are several different ways of initializing […]

Read More

Working with Jaxl – A Networking Library in PHP – Part 1 – An Introduction, Philosophy and History

Development of Jaxl library started way back in December’07 while I was working on a self-initiated project called Gtalkbots. The project is now dead, if you are interested in knowing more about it go through Gtalkbots BlogSpot. Jaxl v1.x was first released in Jan’09 and about a year later in Aug’10 Jaxl v2.x was released. First two versions were released as JAbber XMPP Library for writing clients and external server components. While working on my startup Jaxl – A Platform As A Service (PAAS) for developing real-time applications, I started experiencing v2.x limitations when my external server side components were unable to process XMPP packets at the speed they were sent by ejabberd server. I started restructuring and refactoring the library which gave birth to Jaxl v3.x. Since v3.x was initially being used for developing the entire infrastructure, it shaped […]

Read More

Announcing Jaxl v3.x – asynchronous, non-blocking I/O, event based PHP client/server library

Jaxl v3.x is a successor of v2.x (and is NOT backward compatible), carrying a lot of code from v2.x while throwing away the ugly parts. A lot of components have been re-written keeping in mind the feedback from the developer community over the last 4 years. Also Jaxl shares a few philosophies from my experience with erlang and python languages. Jaxl is an asynchronous, non-blocking I/O, event based PHP library for writing custom TCP/IP client and server implementations. From it’s previous versions, library inherits a full blown stable support for XMPP protocol stack. In v3.0, support for HTTP protocol stack was also added. At the heart of every protocol stack sits a Core stack. It contains all the building blocks for everything that we aim to do with Jaxl library. Both XMPP and HTTP protocol stacks are written on top […]

Read More

How to Write a Spelling Corrector in Erlang (ESpell)

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, … Recently i have even started churning my application html pages via erlang using erlydtl (an Erlang implementation of the Django Template Language). Years ago, i gave a successful shot at implementing Peter Norvig’s Spell Corrector in PHP. Last weekend i attempted the same “Spell Corrector” algorithm in about 45 lines of Erlang code. ESpell: Complete code file with comments and explaination can be found here: https://github.com/abhinavsingh/espell -module(espell). -define(alphabet, “abcdefghijklmnopqrstuvwxyz”). -export([start/0, correct/1]). %% %% API Functions %% %% @doc start spell checker start() -> train(words()). %% @doc returns most probable correct […]

Read More

JAXL library – List of available hooks for various XMPP events

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. Registering callback on XMPP events 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. When application callback’d method is a function: function postAuth($payload, $jaxl) { } $jaxl->addPlugin(‘jaxl_post_auth’, ‘postAuth’); When application callback’d method is a public static method of a class: class MyXMPPApp { public static function postAuth($payload, $jaxl) { } } $jaxl->addPlugin(‘jaxl_post_auth’, array(‘MyXMPPApp’, ‘postAuth’)); When application callback’d method is […]

Read More

How to write External Jabber Components in PHP using Jaxl library?

Jabber Component Protocol (XEP-0114) documents how XMPP protocol can be used to communicate between servers and “external” components over the Jabber network. XMPP components “bind” 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 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. Refer Jaxl Installation, Usage guide and Example apps if you are new to Jaxl. Demonstrated component bot code can be obtained from Jaxl@github. Using Jabber Component Protocol 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 […]

Read More

XEP 0045 – Multi User Chat (MUC) available methods in Jaxl 2.0

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 using the methods listed below. Refer Jaxl Installation, Usage guide and Example apps if you are new to Jaxl. Here is how this can be done at the top of your application code: // initialize Jaxl instance $jaxl = new JAXL(); // include MUC XEP jaxl_require(‘JAXL0045′, $jaxl); // or simply $jaxl->requires(‘JAXL0045′); Multi-User Chat available methods: Below is a detailed list of methods from multi-user room extension: $jaxl->JAXL0045(‘joinRoom’, $jid, $roomJid.”/”.$nick, $history=0, $type=’seconds’) $jaxl->JAXL0045(‘exitRoom’, $jid, $roomJid) $jaxl->JAXL0045(‘kickOccupant’, $fromJid, $nick, $roomJid, $reason=FALSE, $callback=FALSE) $jaxl->JAXL0045(‘getRoomConfig’, $jid, $roomJid, $callback=FALSE) $jaxl->JAXL0045(‘setRoomConfig’, […]

Read More

PHP Code, Setup and Demo of Jaxl boshchat application

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 download and install this sample web application on your systems: Clone the development branch of Jaxl library root@ubuntu:~/git# git clone git@github.com:abhinavsingh/JAXL.git root@ubuntu:~/git# cd JAXL/ root@ubuntu:~/git/JAXL# If you are not familiar with git, simply visit JAXL@github, click Download Source and extract under ~/git/JAXL directory on your system Once inside Jaxl source directory, build the latest development package root@ubuntu:~/git/JAXL# ./build.sh building… Install Jaxl library (view installation detail and options) root@ubuntu:~/git/JAXL# ./build.sh install uninstalling old package… installing… Setup web chat application Jaxl library is default installed under /usr/share/php/jaxl […]

Read More