Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Build a web-based notification tool with XMPP

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

Ben Werdmuller (ben@benwerd.com), Consultant and writer, Freelance
Photo of Ben Werdmuller
Ben Werdmuller is a web strategist and developer who has specialized in open source platforms for more than 10 years. He co-founded and was the technical lead for Elgg, an open source social-networking framework. Ben blogs regularly at http://benwerd.com/.

Summary:  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.

Date:  22 Jun 2010
Level:  Intermediate PDF:  A4 and Letter (259 KB | 32 pages)Get Adobe® Reader®

Activity:  229012 views
Comments:  

Before you start

This tutorial introduces you to the real-time web and takes you through some of the reasons for building real-time web applications. You'll learn techniques that allow you to create responsive, continually updated web applications that conserve server resources while providing a slick user experience.

About this tutorial

Frequently used acronyms

  • DOM: Document Object Model
  • HTML: HyperText Markup Language
  • HTTP: Hypertext Transfer Protocol
  • REST: Representational State Transfer
  • RSS: Really Simple Syndication
  • URL: Uniform Resource Locator
  • XML: Extensible Markup Language

Real-time web applications allow users to receive notifications as soon as information is published, without needing to check the original source manually for updates. They have been popularized by social-notification tools like Twitter and Friendfeed, web-based collaboration tools like Google Wave, and web-based chat clients like Meebo.

The Extensible Messaging and Presence Protocol (XMPP) is an XML-based set of technologies for real-time applications, defined as networked applications that continually update in response to new or changed data. It was originally developed as a framework to support instant messaging and presence applications within enterprise environments.

In this tutorial you will build Pingstream, a simple tool that continually updates itself with RSS feed updates as they are published (see Download for the Pingstream source code). Along the way you will:

  • Learn why XMPP is particularly suited to web applications
  • Learn about the components of XMPP communication
  • Install and configure the Openfire XMPP server
  • Connect to the XMPP server using PHP and the XMPPHP library
  • Check for new items in an RSS feed and transmit them over XMPP
  • Use Strophe and jQuery to connect to an XMPP server over HTTP using Bidirectional-streams Over Synchronous HTTP (BOSH)
  • Display XMPP notifications in a web page

Prerequisites

This tutorial assumes that you have some familiarity with developing web applications in PHP, although little advanced programming is involved. You should also have some experience with HTML and JavaScript. Experience with the jQuery JavaScript framework might be handy. No prior familiarity with XMPP or similar technologies is required.

To follow along with this tutorial, you must have the following server software installed and running:

  • PHP 5.2 or higher
  • Apache HTTP Server
  • MySQL

As you progress through the tutorial, you will also download and install the following software and libraries:

  • Openfire
  • jQuery
  • Strophe
  • XMPPHP
  • Last RSS

You might also find the MySQL server tool phpMyAdmin useful. If you are using a desktop machine to test your real-time web application software locally, you might find XAMPP useful for managing the installation and running of a test web server infrastructure.

See Resources for links to all the tool downloads.

1 of 10 | Next

Comments



static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=XML, Web development, Open source
ArticleID=497119
TutorialTitle=Build a web-based notification tool with XMPP
publish-date=06222010
author1-email=ben@benwerd.com
author1-email-cc=dhatten@us.ibm.com