23,27 €
As more users access the Web from their phones and other handhelds, web developers need to learn techniques for targeting these new devices. Sites such as Twitter, Facebook, and Google target mobiles with their services and products. Companies use mobile services to provide staff access to their applications while away from a computer.
This book is a complete, practical guide to writing mobile websites and applications. You will learn how to create mobile-friendly websites, adapt your content to the capabilities of different devices, save bandwidth with compression, and create server-side logic that integrates with a mobile front end. You will also see other methods for integrating your web application with mobile technology: sending and receiving MMS and SMS messages, accepting mobile payments, and working with voice calls to provide spoken interaction.
The book illustrates every technique with practical examples, showing how to use these development methods in the real world. Along the way we show how an example pizza delivery business can use these methods to open up to the mobile web.
Whether you want to provide customers and users of your public website with new ways to access your services, or build applications so that staff can stay up to date while on the road, this book will show you all you need to build a powerful mobile presence.
Technologies and tools covered in the book
PHP, JavaScript, AJAX, XHTML Mobile Profile (XHTML MP), Wireless CSS, WAP 2.0, Tera WURFL, MyMobileWeb, Mobile Web Toolkit, Image Server, GAIA Image Transcoder, HAWHAW , ready.mobi, Nokia's Mobile Internet Toolkit , SMIL, Voxeo's Prophecy server, VoiceXML (VXML), grXML, Frost library, WALL, WURFL, SMS, MMS, mobile payment gateways, mobile widgets, Mobile AJAX, Android, Google Gears, and Dojo Offline.
Mobile Web Development shows you how to build a mobile presence for your web applications and sites. It covers targeting different mobile web browsers, sending and receiving SMS and MMS messages, accepting mobile payments, and developing voice- and touchtone-response systems.
The author adopts a fast-paced, practical approach to developing for the mobile web. The book focuses on solutions, pragmatic tips, and fast results rather than theory.
Each chapter focuses on an aspect of taking a pizza delivery company onto the mobile web. This ensures that the chapters remain practical and realistic, focusing on getting things done. The book also provides discussion and reference material to help you apply the techniques to your own projects.
This book is for web developers who want to provide mobile support for their applications.
The book assumes some knowledge of HTML, CSS, and JavaScript. The reader should also know a server-side language. The examples in the book use PHP, but can be adapted easily to other languages. The book does not use J2ME, focusing instead on using the phone's web browser and other standard features.
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 281
Veröffentlichungsjahr: 2008
Copyright © 2008 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, Packt Publishing, nor its dealers or distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: February 2008
Production Reference: 1300108
Published by Packt Publishing Ltd.
32 Lincoln Road
Olton
Birmingham, B27 6PA, UK.
ISBN 978-1-847193-43-8
www.packtpub.com
Cover Image by Bharath Kumar (<[email protected]>)
Author
Nirav Mehta
Reviewer
Michael Peacock
Senior Acquisition Editor
David Barnes
Development Editor
Nikhil Bangera
Technical Editor
Ajay Shanker
Editorial Manager
Mithil Kulkarni
Project Manager
Abhijeet Deobhakta
Project Coordinators
Snehal Raut
Zenab Kapasi
Indexer
Hemangini Bari
Proofreader
Chris Smith
Production Coordinators
Aparna Bhagat
Shantanu Zagade
Cover Work
Aparna Bhagat
Nirav Mehta is renowned for his entrepreneurial ventures, his breakthrough ideas, and his contribution to open source. Nirav leads a software development company—Magnet Technologies—from India that specializes in Rich Internet Applications, Web, and Mobile. Nirav believes in simplifying the most complicated ideas and presenting them in lucid language.
Over the last ten years, Nirav has written and spoken on a variety of topics. He has also been instrumental in localization efforts in India and training programmers to be effective developers. He blogs at www.mehtanirav.com.
My love and thanks to my parents. It's your support and freedom that lets me do all things I love! Thank you!
I would like to thank Mayank Sharma, for his recommendations. Without you, the book wouldn't be possible.
Thanks to David Barnes, Packt's Acquisition Editor. Your comments, guidance, and blog have inspired me a lot.
I would like to thank Micheal Peacock and the team at Packt—Nikhil Bangera, Patricia Weir, Snehal Raut, Ajay Shanker, Sagara Naik, and everyone else. You guys are amazing! I will always remember how hard you worked to get the book out near my wedding, and the superb suggestions throughout.
Of course, the team at Magnet! Ashok, Vishal, and Harshad—you have been with me in all the ups and downs, I cherish your partnership. All Magneteers, thank you for being a great team!
I also appreciate the readers of this book! I believe you are up to something big, and hope my work helps you achieve it.
And finally, my wonderful wife, Nikita. I stole time from you for the book. Thanks for your constant love, encouragement, and reminders!
Michael Peacock is a web developer and senior partner of Peacock, Carter & Associates (http://www.peacockcarter.co.uk) a web design and development business. Michael loves building websites and web applications, and when he isn't, likes to read, watch films, and occasionally take part in amateur dramatics.
As more users access the Web from their phones and other handhelds, web developers need to learn techniques for targeting these new devices. Sites such as Twitter, Facebook, and Google target mobiles with their services and products. Companies use mobile services to provide staff access to their applications while away from a computer.
This book is a complete, practical guide to writing mobile websites and applications. You will learn how to create mobile-friendly websites, adapt your content to the capabilities of different devices, save bandwidth with compression, and create server-side logic that integrates with a mobile front end. You will also see other methods for integrating your web application with mobile technology: sending and receiving MMS and SMS messages, accepting mobile payments, and working with voice calls to provide spoken interaction.
The book illustrates every technique with practical examples, showing how to use these development methods in the real world. Along the way we show how an example pizza delivery business can use these methods to open up to the mobile web.
Whether you want to provide customers and users of your public website with new ways to access your services, or build applications so that staff can stay up to date while on the road, this book will show you all you need to build a powerful mobile presence.
Chapter 1 introduces the Mobile Web and we'll see why mobile web is the next big thing.
Chapter 2 is our first look at the example site we'll be building in the book: "Pizza on the Run" (POTR). Specifically, we look at: picking the best method to deliver your site to mobile browsers, designing navigation and information architecture, setting up a development environment, learning XHTML Mobile Profile—the presentation language for mobile applications, and developing Pizza On The Run's mobile site homepage.
Chapter 3 looks at: designing layouts for the mobile web, using Wireless CSS in design, being aware of differences in mobile browsers, creating the database and code architecture for our example site (POTR), using forms on the mobile web, handling user authentication, testing our work in simulators, constraining user input with Wireless CSS, and applying special effects using Wireless CSS.
Chapter 4 covers: understanding the Lowest Common Denominator method, finding and comparing features of different mobile devices, deciding to adapt or not, adapting and progressively enhancing the POTR application using Wireless Abstraction Library, detecting device capabilities, evaluating tools that can aid in adaptation, and moving your blog to mobile.
Chapter 5 specifically looks at: running a ready.mobi test on your site, creating the structure, design, markup, and navigation for best user experience, and collecting user behavior data to keep enhancing the site.
Chapter 6 looks at sending text messages, and in the process covers the fundamentals of using third-party services for messaging. We specifically take a look at: updating order status for POTR, selecting an SMS gateway provider and setting up an account, sending text messages using the gateway's API, understanding how an SMS message is delivered, getting delivery status updates, setting up our own SMS gateway, and sending bulk messages.
Chapter 7 covers: creating Multimedia Messages for special offers at POTR, controlling message presentation, sending Multimedia Messages through our gateway, and receiving photos from customers via MMS.
Chapter 8 explores and set up a mobile payment system for POTR. Specifically, we look at: getting money through PayPal, evaluating mobile payment methods—their pros and cons, security concerns in mobile payments, using SMS in mobile payment, Premium SMS and Short Codes, and receiving Text Messages via a short code.
Chapter 9 looks at: setting up an interactive voice response platform, playing pre-recorded audio and text to speech, accepting keypad inputs, accepting voice input and doing speech recognition, performing dynamic calculations on input, and integrating with server-side scripting.
Chapter 10 covers how to use AJAX on mobile platforms. We specifically look at: getting pizza recipes via AJAX, enabling AJAX in forms, understanding iPhone application development, and more about building rich mobile apps.
Chapter 11 looks at: trends in mobile web applications, mobile widgets and developments of the browser, connectivity—mobile networks, occasionally connected devices, open Handset Alliance and Google's Android system, and resources to keep abreast of the mobile scene.
You do not need any specific software/hardware to benefit from the book. But:
Feedback from our readers is always welcome. Let us know what you think about this book, what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply drop an email to <[email protected]>, making sure to mention the book title in the subject of your message.
If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or email <[email protected]>.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
Visit http://www.packtpub.com/support, and select this book from the list of titles to download any example code or extra resources for this book. The files available for download will then be displayed.
The downloadable files contain instructions on how to use them.
Although we have taken every care to ensure the accuracy of our contents, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in text or code—we would be grateful if you would report this to us. By doing this you can save other readers from frustration, and help to improve subsequent versions of this book. If you find any errata, report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the Submit Errata link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata added to the list of existing errata. The existing errata can be viewed by selecting your title from http://www.packtpub.com/support.
You can contact us at <[email protected]> if you are having a problem with some aspect of the book, and we will do our best to address it.
This book is dedicated to my parents—Vinod & Nayna and my wife—Nikita; for their love and support
When Evan Williams, founder of Blogger and Odeo, had to pick up what he would do next to revolutionize the Web, he decided to go mobile. Evan returned the VC money to focus on Twitter—a service that allows keeping in touch with friends via alerts to and from your mobile phone (and instant messenger and web)! After six months of launch, Twitter had reached 50,000 active users. The number doubled to 100,000 in just one month after Twitter won the Best Blog award at South By South West conference.
Evan mentioned "Best Blog" was a weird category for Twitter, as Twitter is not a blog. But Twitter's growth has been phenomenal. As Ewan Spence of The Podcast Network puts it, "Twitter has got Americans texting!" And that included a US Presidential candidate!
The way it works is very simple. Whenever you want to update your friends about what you are doing, just pick up your phone, type an SMS, and send it to a special shortcode number. Twitter broadcasts it to all your friends and posts it on your Twitter page. Your friends will know what you are up to, whether they are online or on the move.
If you have a lot of friends, you may love getting text messages about what they are eating and what their cat is doing. Or you may hate the SMS beeps at all odd hours. But it is a fact that Twitter is a big-time success. And it shows where things are moving.
Things are moving mobile!
Broadtexter allows music bands to broadcast messages to their fans via SMS. With a Broadtexter account, the band get a simple widget they can place on their site. Fans register using this widget. When the band are doing a show, they go to Broadtexter, select the area of the show, and send out an SMS broadcast to all those fans with the venue and time of the show. Unlike the conventional thinking that people would not like such updates, the idea has been a hit. Many bands had people coming in and thanking them for the SMS! They weren't doing anything else that evening, and the last minute text message excited them to get to the show. The band not only sold more tickets but also got a new way to keep in touch with fans.
Imagine Twitter or Broadtexter without the mobile connectivity. We will not go to a friend's blog to read short updates on what she or he is doing. We will forget the reminder a band had emailed two days ago about today's event. Twitter and Broadtexter are successful primarily because they allow updates over mobile devices in a quick and convenient manner.
And it is not only text messages. Google has a full blown mobile site. You can access it using a mobile phone or a PDA, and perform a search just like you would do from a desktop. You can navigate the results using the limited keyboard you have on the device and still get the job done.
Web applications are now reaching where their users are. Not just in front of their desktop, but also when they are traveling, or when they are driving looking for a good restaurant in the neighborhood.
Welcome to the world of Mobile Web!
Simply put, mobile web refers to the Web being accessed from mobile devices like cell phones and PDAs. The reach and capabilities of mobile devices has grown phenomenally over the last three years. Almost all mobile phones now can access the Internet in some or the other way. All PDAs have a tiny web browser built in. People are getting used to accessing information from the Web over their phones. Many use PDAs to check their emails and manage other bits of information. Early adopters of technology have already been blogging from their mobiles and viewing online photos and videos while they are traveling. Mobile web is all of that. Any website accessed from a mobile device is mobile web—whether it's been tailored to work on a mobile or not!
We use mobile phones mainly to communicate with people—either voice or text. PDAs so far have been used for managing schedules and contacts, apart from some occasional office productivity work and games! The Web on the other hand has evolved greatly over the years. From the early days of simple HTML markup linking a few pages, to the Web 2.0 collaborative ecosystem, things have matured a lot. If you come to think of it, we can't expect a world without the Web or mobile devices today!
You may have done a lot of web programming and might be wondering how you can develop for mobile devices. Or you may want to add mobile features to your existing site. This book will teach you all that. Reading through the book, you can port your website to mobile devices. You can AJAXify your mobile site and integrate SMS or MMS messaging. You will even be able to accept payments via mobile and use intelligent interactive voice-response systems. With this book, you can bring web applications to mobile devices, integrating them with mobile-specific features!
By the way, we are not going to talk about mobile application development. We are not even going to talk about web application development. You don't need any J2ME knowledge or C++. All we assume is that you have a basic knowledge of HTML and some server-side programming technology. We will use PHP for the examples in the book, but you can easily customize them to any other language. We will explain different mobile technologies, so it's alright if you don't know them already!
Go to any electronics store, and you will have hundreds of mobile phones to choose from. The shelf life of a mobile phone model is less than 18 months now. People change their phones every two years, and companies push new models every month. Mobile phones are not the only mobile devices! With pocket-sized computing devices—PDAs, micro notebooks, and even handheld notebooks—the options are bewildering. We will include both mobile phones and pocket-sized devices whenever we refer to mobile devices. Let us discuss some specific features and limitations of these mobile devices.
Mobile phones are the largest segment of mobile devices. Mobile phones typically come in "candy bar", "sliding box", or "clam shell" form. You surely have seen a variety of them. Mobile phones have a specially designed processor and run some kind of operating system. Symbian and Windows Mobile are widely used operating systems on mobile phones, and many phone manufacturers develop their own systems as well.
The most important use of a mobile phone is to talk. Then, you could use it to take photos, send messages, and play music. In the last three years, mobile phones have seen a number of innovations. All this has resulted in a vast variety of devices in the market—from simple feature phones to smart phones.
Color phones are a norm now, yet there are millions of monochrome devices around. The screen size, resolution, and color density varies greatly. You will see screen sizes from 120x120 to 320x240 and more.
The standard input mechanism for mobile phones is a 12-key pad with additional function keys. Some phones have a joystick that can be used for navigation. Wider-screen models sometimes feature a stylus-based input system or an on-screen keyboard. Phones like the iPhone have touch-sensitive panels, and some have accessories that you can attach to get a full QWERTY keyboard.
Mobile phones come in sizes that fit your pocket—some are incredibly small and some as big as a pencil box. Sleek and slim designs are in vogue—especially because a mobile phone is also a style statement. Having the latest model is a status symbol in many markets!
Referred to as SMS (Short Message Service, Message, or Text depending on the part of the world you are from), these 160 character text messages have revolutionized mobile usage. SMS is now used for all sorts of business and entertainment purposes. MMS (Multimedia Message Service) allows you to send pictures, sounds, and full videos to others just as you send emails.
But if there is one thing that changed mobile phones from communication devices to consumer goods, it is the camera. Starting with VGA quality images (640x480 pixels), today's mobile phones are equipped with five-megapixel cameras, flash, and other tools to add effects to the photographs. Millions have turned into amateur photographers just because of the camera in their phone. The Internet is full of funny and dirty video clips taken from mobile phones.
Not everyone could afford an iPod. So, mobile companies started adding MP3 support to their phones. Use of MP3 ringtones and swapping music files has become a norm. Listening to radio using the phone has shot up too.
And that's not all. As these phones are little computers themselves, you can develop applications that extend their functionality or add new features. Application development over Symbian, J2ME, BREW, or Palm is very popular. Each phone comes with a set of applications and utilities, and there are thousands of developers around the world who develop games and utility applications that run on mobile phones. Google's Android allows you to even replace the built-in applications—giving you full control over your device.
Most of the mobile phones today come with some sort of a web browser. Opera Mini is the most popular browser but there are many more. Different browsers support different features, and break some! Testing across browsers is one of the biggest challenges in mobile web development. The situation is much worse than desktop browsers, and we will see more on this in the coming chapters. The connectivity to the Web depends on the carrier you are on. You may be on GPRS, 3G, Bluetooth, WiFi, or anything in between.
Another class of mobile devices is PDAs. Personal Digital Assistants have been around for quite some time and have evolved over this period. They contain many business and productivity applications—email, office productivity, and custom-built software. Typically, they have a QWERTY keyboard—either in the device or onscreen. Phone functionality is an add-on for PDAs, and most consumer PDAs are smart phones now. These handheld devices are merging with phones now, and are very popular with business users.
There are other devices that are used in a mobile fashion. Many embedded devices use mobile technology for communication. Micro notebooks, watches, or cars can be classified here as well. Gaming consoles are also used as web clients these days. We expect many hybrid devices to come up in the next few years leveraging higher computing power and mobile communication technology.
What do people do with all these devices? Understandably, it's much more than voice! Let's see the usage patterns of mobile devices.
Mobiles are used for voice communication generally, but the usage of mobile devices for data communications is growing rapidly. Data usage includes simple things like SMS to mobile web, video and TV on mobile, and other innovations. For mobile companies, this is billions of dollars of additional revenues and for users, these are value-added services. This growth is seen across the globe. Japan, the USA, and China are leading the pack in data usage, but other developed and developing nations are not far behind.
According to a Chetan Sharma's consulting report (http://www.chetansharma.com/MobilePredictions2008.htm), Japan and Korea are the benchmarks in terms of mobile data usage, but the USA will soon be the largest revenue-generating market. Brazil, the Netherlands, and Czech regions are already doing more than 30% of their revenues from mobile data. Though a large part of this money is from SMS, other services are gaining larger shares. The USA has 50-60% data revenues from non-SMS services, while Japan and Korea have a higher 70-75%. This trend suggests there is a huge use already of mobile web applications, and it is going to continue not only in these regions but other parts of the world too.
Another interesting thing is that the western European region reports 100% of the population has mobiles—though part of this is due to double phones with single persons and dual reporting. The USA has more than 75% reach. Mobile subscribers around the world have already reached 3 billion, and China and India together are adding close to 13 million every month.
At the same time, the speed of wireless communications is increasing worldwide. Many countries already have 3G and more are gearing up for it. Some are considering 4G and better technologies for faster wireless access. All in all, it means that we can offer services that require faster net access!
Services that were earlier not possible—like video—have already started appearing and will continue to grow. Subscribers set wallpapers, ring tones, ringback tones, true tones, and download full tracks to listen to on their multimedia phones. Most are willing to pay for games. Many companies experimenting (and some betting on) mobile advertising—though 79% of users felt such ads intrusive!
Mobiles are transforming from communication devices to content devices, and will further transform to transaction devices. The evolution is happening faster than we think.
For every computer in the world, there are three mobile phones. Studies show that by 2010, there will be 4 billion mobile phones on this planet, and if we see the 2007 numbers, we may reach there well before 2010. 4 billion is 60% of the global population! Mobiles have provided an affordable and accessible computing platform. For most users, their mobile phone is their primary connection with high-tech, and more importantly the Web!
At the same time, the maturity of the mobile market differs widely in different regions. Japan and Korea are the most advanced, whereas Brazil, Russia, India, and China are seeing a volume growth. In developed countries, most people have exposure to computers and they adopt mobile web applications faster. In developing countries, communication and entertainment applications are proving more successful. There is a huge potential for low-cost services that can benefit large portions of the population.
When you build your mobile web application, make sure you understand the market well and launch the product accordingly. You may be too early or too late otherwise!
When people access the Web from their mobile phones, they are in a different context. They may be traveling, waiting for something else to happen, looking for a nearby restaurant, wanting to take care of some chore or just browsing for fun. Mobiles are hardly used like the typical desktop is. Here is the first lesson to learn in mobile web application development:
