Write real-time web applications with XMPP, PHP, and JavaScript

I’ve written a tutorial for writing XMPP-based web applications over at IBM DeveloperWorks:

Real-time web applications are networked applications, with web-based user interfaces, that display Internet information as soon as it’s published. Examples include social news aggregators and monitoring tools that continually update themselves with data from an external source. In this tutorial, you will create Pingstream, a small notification tool that uses PHP and JavaScript to communicate over the Extensible Messaging and Presence Protocol (XMPP), a set of XML technologies designed to support presence and real-time-communications functionality.

You can read the whole tutorial here. IBM have made it a featured article, commenting, “bet you have it up and running before lunch.” I hope you find it useful. (And don’t forget to check out my introduction to Activity Streams, also written for IBM.)

Photo: IBM by antonfortunato, released under a Creative Commons license.






3 responses to “Write real-time web applications with XMPP, PHP, and JavaScript”

  1. Arnold Shore Avatar
    Arnold Shore

    Thanks for yr article re XMPP-based chat. But my requirements differ somewhat. This is for a free, open source php-based. computer-aided-dispatch application I’ve written. I want very much to keep the package in a single-language implementation since a major portion of users are newbies to web application install and use. Further, the package is self-contained and relies on no third-party services (other than GMaps for client-side operations) so the xmpp services need to be intrinsic to the application.

    My question: Do you see any practical way to substitute some php scripting – either custom or an existing package – in place of the Openfire xmpp server function? A key element here can be the php PCNTL extension, which seems to be omitted from the ISP’s I currently use.

    Thanks for any insights on these points.

  2. Nathan Brown Avatar
    Nathan Brown

    Very nice tutorial; thank you very much! One thing I tried to do was open multiple ‘message recipient’ windows, but apparently, the newest window (XMPP connection) overtakes the previous connection. This way, with a generic user account, only one user with one session can see updates. Any ides on how to perform a “message broadcast” so multiple users could watch for updates, simultaneously?

    1. Ben Werdmuller Avatar

      You’d need each visitor to have a separate XMPP account, I think. Then subscribe both to the same channel, and send your message to that channel.

      In the time since I wrote the tutorial, my thoughts have changed, and I wonder if it isn’t smarter to use queuing servers and long polling rather than actual XMPP. It still definitely has its uses, but perhaps less so on the web.

Leave a Reply

Your email address will not be published. Required fields are marked *