MO HTTP

From SMS Wiki
Jump to: navigation, search

Mobile Originated Messages

You can instruct your account to forward all incoming SMS messages to your external application. This is done by instructing your account with our gateway service to, upon receipt of each incoming message, make an HTTP Post to your web server/page. In order for this to work you must have an externally accessible web page expecting to receive HTTP messages using HTTP POST.

Here is how the process works (this document assumes that you already have a paid account with our service. If not, please open here:

  • Create your web page and post it on your server. See parameters that your web appliction must handle
  • Contact us and provide us the URL to your application
  • We will register your URL with your account and create a forwarding rule which will forward each incoming SMS message to your application (via your URL)

That's it. After this setup is done, each incoming SMS message coming to your account will be forwarded to your application where you can process it using your custom business logic.

Receiving SMS

The method of receiving Inbound SMS messages is by way of HTTP POST. A few variables are passed in the body of the POST.

  • name - Username to which SMS came (useful if you have multiple accounts with our service)
  • sender - Mobile phone number of the sender. The number is international format (US and Canada this means 11-digit number starting with "1")
  • data - Text of incoming SMS
  • carriercode - (shortcode accounts only) MCC/MNC identifying the sender's mobile network. You must store this with the number and pass it back when sending messages
  • inboundnumber - (for short/long code accounts only) Gateway number that received the message. This is useful if you have multiple dedicated numbers associated with your account

Examples

Example 1 - No short code

You can use the following HTML to emulate what our server will send your service.

http://myurl.com/myaction?sender=17789999999&data=hello&name=username

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<title>Received SMS Emulator (Via HTTP POST)</title>
	</head>
	<body>
		<form id="emulator" name="emulator" method="post" action="http://sms.yourdomain.com/incoming.php">
			<table>
				<tr>
					<td>Sender:</td>
					<td>
						<input name="sender" type="text" id="sender" value="17789999999"/>
					</td>
					<td>sender</td>
				</tr>
				<tr>
					<td>Message:</td>
					<td>
						<input name="data" type="text" id="data" value="Hello"/>
					</td>
					<td>data</td>
				</tr>
				<tr>
					<td>User Name:</td>
					<td>
						<input name="name" type="text" id="name" value="Account_Name"/>
					</td>
					<td>name</td>
				</tr>
				<tr>
					<td colspan="2" align="right">
						<input type="submit" name="Submit" value="Submit"/>
					</td>
					<td>&nbsp;</td>
				</tr>
			</table>
		</form>
	</body>
</html>


Example 2 - Short code

You can use the following HTML to emulate what our server will send your service. You will notice that in addition to the three standard variables, in this case carrier code as well as incoming gateway number are passed as parameters.

http://myurl.com/myaction?sender=17789999999&data=hello&name=username&inboundnumber=987333&carriercode=302370

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<title>Received SMS Emulator (Via HTTP POST)</title>
	</head>
	<body>
		<form id="emulator" name="emulator" method="post" action="http://sms.yourdomain.com/incoming.php">
			<table>
				<tr>
					<td>Sender:</td>
					<td>
						<input name="sender" type="text" id="sender" value="17789999999"/>
					</td>
					<td>sender</td>
				</tr>
				<tr>
					<td>Message:</td>
					<td>
						<input name="data" type="text" id="data" value="Hello"/>
					</td>
					<td>data</td>
				</tr>
				<tr>
					<td>User Name:</td>
					<td>
						<input name="name" type="text" id="name" value="Account_Name"/>
					</td>
					<td>name</td>
				</tr>
				<tr>
					<td>Inbound Number:</td>
					<td>
						<input name="inboundnumber" type="text" id="inboundnumber" value="987333"/>
					</td>
					<td>inboundnumber</td>
				</tr>
				<tr>
					<td>Carrier Code:</td>
					<td>
						<input name="carriercode" type="text" id="302370"/>
					</td>
					<td>carriercode</td>
				</tr>
				<tr>
					<td colspan="2" align="right">
						<input type="submit" name="Submit" value="Submit"/>
					</td>
					<td>&nbsp;</td>
				</tr>
			</table>
		</form>
	</body>
</html>

back