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 developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

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]

Create an alerts system using XMPP, SMS, pureXML, and PHP

Develop a Euro currency exchange rate application with automatic updates

Joe Lennon, Software developer, Freelance
Photo of Joe Lennon
Joe Lennon is a 24-year-old software developer from Cork, Ireland. Joe is author of the forthcoming Apress book Beginning CouchDB, and has contributed several technical articles and tutorials to IBM developerWorks. In his spare time, Joe likes to play football (soccer), tinker with gadgets and work on his Xbox 360 gamer score.

Summary:  Thanks to the native XML support that pureXML® offers IBM DB2® database developers, you can load XML data directly into your database, freeing up development time to add functionality to your application. Follow along in this tutorial to import an XML file with Euro foreign exchange rates into an IBM DB2 database and use special XQuery and SQL/XML functions to split this XML into separate database rows. You will also create a PHP script that pulls down new rates from the European Central Bank (ECB) Web site each day. Then you will extend the script to send update alerts to a Google Talk user using the XMPP protocol, and to a cell phone by SMS text message using the Clickatell SMS gateway service. Finally, you will create a PHP script that generates a PNG (Portable Network Graphics) graph of this data.

Date:  24 Nov 2009
Level:  Intermediate PDF:  A4 and Letter (1023 KB | 38 pages)Get Adobe® Reader®

Activity:  32812 views
Comments:  

Before you start

This tutorial is aimed at Web application developers who want to develop database-driven applications that are powered by an IBM DB2 pureXML database. The reader should be familiar with basic PHP code and be able to work with the Windows command prompt in order to follow the tutorial. Some experience with database management systems and the SQL language is also required. By the end of this tutorial, you will learn how to create object-oriented PHP Web applications that take advantage of a pureXML database.

About this tutorial

Frequently used acronyms

  • API: Application programming interface
  • HTTP: Hypertext Transfer Protocol
  • RFC: Request for comments
  • RPC: Remote procedure call
  • SMS: Short Message Service
  • SOAP: Simple Object Access Protocol
  • TCP: Transmission Control Protocol
  • XML: Extensible Markup Language
  • XMPP: Extensible Messaging and Presence Protocol

IBM DB2 Express-C includes pureXML, a way to store XML data natively in a relational database table. pureXML allows the user to query, index, and manipulate this XML data. You can use a series of functions to work with a hybrid of relational and XML-based data in a seamless fashion. This enables the development of applications that utilize the strengths of both traditional relational database tables and XML data.

XML is now widely used as a portable data storage format, and you will frequently find public data and Web services providing access to their data in XML format. By using IBM DB2 Express-C you can develop applications that load this XML data directly into the database, and create applications that are driven by this data without having to convert it into relational columns. Of course, sometimes it makes sense to take this data and convert it, and in this tutorial you will see a mix of various techniques for working with XML in DB2.

In this tutorial, you will learn how to create an alerts system that polls the Euro foreign exchange rates from the European Central Bank Web site on a daily basis. If a new set of rates are found, the application will load this data into a DB2 database, and it will also send an alert in two ways: as a Google Talk (XMPP) instant message, and as an SMS text message to a cell phone. You will also learn how to import bulk XML data into a DB2 database, and in this case, you will load the entire history of Euro foreign exchange rates, dating all the way back to 1999, when the Euro currency was first introduced. Later in the tutorial, you will develop a PHP script that generates a chart of the maximum exchange rates for each month of the current year.


Prerequisites

To follow the steps in this tutorial, you will need to install the following software:

  • IBM DB2 Express-C 9.5
  • PHP 5.2
  • XMPPHP library

See Resources for the links to the download sites and to articles that walk you through the installation and configuration of the above software.

Project folder

This tutorial assumes that you store all of the source code in the folder C:\currency. If you have not already done so, create this folder now by opening Windows® Explorer and navigating to the root of the C: drive. In there, right-click and choose New>Folder. Name the folder currency. Alternatively, download the source code for this tutorial and extract the folder to your C: drive.

Configuring PHP

You need to make some changes to your PHP configuration file to follow this tutorial. In php.ini locate the line that reads something like error_reporting = E_ALL and change it to: error_reporting = E_ERROR.

Next, find the line similar to: display_errors = On and change it to read: display_errors = Off. Finally, scroll down the file until you find the section for PHP extensions. Many of these extensions will be disabled by default, with a semi-colon at the start of the line commenting out this particular feature. To enable features, simply remove the semi-colon at the start of the line. Now, find these lines in Listing 1 and make sure the semi-colon (;) at the beginning of each is removed.


Listing 1. Removing the semi-colons

extension = php_curl.dll
extension = php_gd2.dll
extension = php_mbstring.dll
extension = php_openssl.dll
extension = php_sockets.dll

1 of 9 | Next

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=XML, Information Management
ArticleID=449032
TutorialTitle=Create an alerts system using XMPP, SMS, pureXML, and PHP
publish-date=11242009
author1-email=joe@joelennon.com
author1-email-cc=dhatten@us.ibm.com

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.