万千英语族 英语爱好者的家园
在线英语广播
在线英语词典
在线杀毒查毒
77TEK
万千英语族 英语频道 首页 翻译文化 阅读写作 听力口语 学习方法 听歌学英语 趣味英语 好贴无限 数字生存
阅读字体:

Open the Mobile Gateway with SMS and MMS Messaging

www.iselong.com 作者:

If you've ever used your mobile device to check your Yahoo! Mail or check the news, you've used a Short Messaging Service (SMS). This article takes you through the inner-workings of these near-ubiquitous services, finally demonstrating how to SMS-enable your weblog. 

by Premshree Pillai September 2, 2004
 
 
 
Short Messaging Service (SMS) services are becoming near-ubiquitous. Who among us has not used their cellphone to check the latest cricket score or to get the latest news? One very popular service, available through most carriers, is Yahoo's 8242 service. This service allows you to check your Yahoo Mail, use Yahoo Instant Messenger, or check scores, news, etc. When you access this type of service, you're using both the carrier's network and the service provider's network (in this case Yahoo). There are also many carrier-dependent services, in which case you make use of the carriers' network alone.
To provide you with these services, these networks (Yahoo, or any of the carriers like Hutch, AirTel, etc.) implement something known as a gateway. A gateway is nothing but—as the word suggests—an entrance to the network. In the case of mobile-based services, these gateways are called mobile-to-network gateways,or simply mobile gateways.

This article uses a low-level implementation to demonstrate how a mobile-to-Web gateway works. The example network uses the Web, but carriers and service providers may use their own networks.

What Is a Gateway?  


Figure 1. A Typical Gateway: The image shows a typical gateway.

Typically, a service has many users. The gateway (depicted as a thick line in the service network in Figure 1) performs the following tasks:

Implements a queuing mechanism to service each incoming request.
Determines whether the the service requested is acceptable.
Sends a response granting the service.
Thus, a gateway acts as a filter between the service network to the service requester (user's) network.
The sections that follow provide an overview of an SMS-to-Web gateway, and an MMS-to-Web gateway. For simplicity's sake, the examples assume only one user. This leaves the task of implementing mobile gateways that service incoming mobile requests (in the form of SMSes and MMSes) on a continuous basis.


The SMS-to-Web Gateway
Here are the three things a required to implement a gateway:

  1. An incoming service request from a mobile (in this case in the form of SMSes).
  2. A number to send the service request.
  3. A service network (typically).

To satisfy the first of the above requirements, you may use any cell-phone (note that the network type—whether GSM or CDMA—determines availability of service numbers).
 

The main task is to provide your own service, using your own gateway. Since you don't have your own service number or your own network, you'll need to use an intermediary service—like Yahoo Mail for SMS—as a way to send requests. For your network, you'll simply use the Web.

Before you implement your gateway, you'll need to decide what service you want to offer. This example uses a simple model: a user sends SMSes which are displayed as plain text on the sender's home computer.

The user will send messages using a service like Yahoo Mail for SMS. This service is offered by Yahoo to select carriers (like Hutch, Orange, etc.). Users are able to send emails from their Yahoo mail account using SMS. Here's how to send an email using Yahoo Mail:

Login to your account by SMSing the following to 8243 (this is Yahoo's service number, more commonly called the Yahoo Gateway):


in username password

To send an email, SMS the following to 8243:

to recipient@host.com mail_body

In this case, you're the only user, so the recipient email address will be one of the user's email addresses.
Because the Web is your intermediate network, the user's home machine should be connected to the internet at all times. Your gateway—which is software—will be implemented on this machine.

The gateway is like a daemon—whenever a new request comes in, the gateway services it. More specifically, the gateway is an endless (infinite) loop that sleeps in between events for a pre-defined time, meaning it's not a tight infinite loop. In this case, the service is simply displaying the SMS.

 
Figure 2. The Scheme of Things: This shows how the gateway fits into the scheme of things.

Take a more detailed look at how the gateway grants service requests:

  • The user sends an SMS to one of his own email addresses. The email address could be a Web mail account or a POP3 account, which is even better.
  • The gateway is running in the background. It uses the Internet to access the user's mail account to check for new emails. New emails are filtered to get only those emails that have been sent via SMS. The simplest way to do is to check for the subject, which is typically set to '[none]' when using Yahoo Mail for SMS.
    The gateway parses the raw email source, and extracts only the body of the email, simply displaying it in the console.
  • After one round of processing, the gateway "sleeps" for a while.
  • After the sleep period is over, it springs back into action.

Now, you have implemented an SMS gateway. The gateway fits into the scheme of things as shown in Figure 2. The pseudocode in Listing 1 shows the overall logic flow for building the gateway.

---

The MMS-to-Web Gateway
Just as you implemented an SMS gateway, you can implement an MMS (Multimedia Messaging Service) gateway. What's the difference between an SMS and an MMS?

SMS messages can only contain text/plain messages, while emails sent using MMSes have textual as well as multimedia data (typically images). Thus, MMS messages are "multipart" messages—the MIME type part of the email could be text/plain, and the other part could be an image/jpeg.

So the only difference between an SMS gateway and an MMS gateway is in how each handles the various MIME extensions of the email.

Note: In an SMS message, the MIME type can be text/plain only, so you don't have to explicitly handle such email messages.

The MMS gateway is identical to the scheme shown above for the SMS gateway.

Listing 2 shows how to implement the MMS gateway as pseudocode.

SMS-to-LiveJournal: An SMS-to-Web Gateway
For those of you who have not heard of LiveJournal, it's a very popular blogging Web site that runs on open-source software. I recently wrote an SMS-to-LiveJournal gateway (simply called SMS2LJ). The source—written in Python—is available under the terms of the GNU Public License (GPL) at http://ljtools.sourceforge.net/.

This tool is similar to the SMS-to-Web gateway that I discussed earlier. Where it differs is in the service provided—using this tool, a user can send an SMS, which then is processed by the gateway, but instead of simply displaying the message on the computer, the message is posted to your LiveJournal account. This allows you to post to your LiveJournal account whenever you are on the move.

Instead of using the display() function, you use the postToLiveJournal() function:


function postToLiveJournal(what) {
server = "http://www.livejournal.com/";
data = {
user: LJ_USER,
password: LJ_PASSWORD,
subject: "",
message: what,
year: time.getYear(),
month: time.getMonth(),
day: time.getDay(),
time_hrs: time.getHours(),
time_mins: time.getMinutes()
}
XMLRPC.post(data, server);
}
Author's Note: In the above pseudocode, the main functions run in an infinite while loop (with some "sleep" period). This was to demonstrate the idea behind how these gateways run continuously, polling whatever they are supposed to (POP3 mailboxes, etc.). However, using an infinite while loop is not a very good idea. Instead, when actually using the script, run the main function only once in the script, and schedule the script using a scheduler like cron.

Using a scheduler makes more sense. If you use a while loop instead, and if for some reason an error occurs, the script would halt. Thus, your gateway will no longer work until you re-run it. Errors in scripts are very common. To avoid such problems, use a scheduler. Even if an error occurs at a particular run, the script will be scheduled to run again.

Using Mobile-to-Web Gateways
The above example (SMS-to-LiveJournal Gateway), shows how to perform "moblogging," or, blogging on the move. An even better way to achieve moblogging is to send multimedia messages using your mobile device—an MMS-to-LiveJournal Gateway. For those interested, I have written one (using Ruby). It’s available here.

There are plenty of ways you could use Mobile-to-Web Gateways:

  • Comment Alert: Most blogging tools allow readers to leave comments to your posts. You can easily create an application that would alert you (by way of SMS or MMS) when you receive a comment. This can be easily achieved by "parsing" your comments page, or even better using an API (if one is available) to keep track of comment counts.
  • Mail Alert: Another very interesting way to use Mobile Gateways is to create a mobile mail alert application. This application would in essence, poll your POP3 mailbox for incoming mails, and when one arrives, it would simply send an email to your gateway address (typically of the form your-mobile-number@your-service-provider). This would make an interesting application for those on the move with handheld mobile devices. In fact, you could even message the entire text of the email, limited, of course, only by the SMS/MMS character limit imposed by your mobile phone operator.
  • Using such gateways, you could provide your own mobile service. For example, you could provide topical news. How? Well, you'd have a primary email address that acts as the target "address" to obtain a news service. People who want the service could simply send a message to that mail address, a typical message being of the form: news whetever-category. Your gateway simply polls your POP3 mailbox for such messages, parses them, and accordingly delivers the services!
There are many other useful ways to use gateways; if you think of one, drop me a line. I hope this article has helped you understand the idea behind gateways. 
 


收藏至ViVi】【论坛】【英语词典】【英语广播】【打印】【评论】【关闭
相关文章:
资料更新时间: 2005-4-28 0:25:51
资料标题:《Open the Mobile Gateway with SMS and MMS Messaging》
检索关键字:Mobile,Gateway,SMS,Gateway,MMS,Gateway
资料编号:8672
资料来源:www.mozat.com
万千英语族或其成员转载此文档旨在传达更多资讯之目的,不代表万千英语族赞同或暗示其内容准确性,对于读者参照本文档操作可能造成的任何损失亦不承担任何责任.
Copyright©2000-2005    万千英语族    Not-All-Rights-Reserved.
 关于我们 友情链接 休闲英语社区 历史上的今天 英文儿歌 意见反馈 网站地图
Powered By 万千英语族CMS文章发布系统 [SQL Version]