AT&T API Platform SDK for Microsoft®  2.3.3
Wrapper classes that allow developers to build robust applications using .NET
 All Classes Namespaces Functions Enumerations Properties
Short Message Service Cookbook

Overview

This cookbook shows you how to develop a Short Message Service (SMS) application using the Platform SDK for Microsoft.
The Platform SDK for Microsoft provides the following methods:

  • Send SMS
  • Get SMS Delivery Response
  • Get SMS
  • Receive SMS
  • Receive SMS Delivery Status

To use these methods in an application, perform the following steps:

  1. Add a reference to the SDK as shown in the About the Cookbooks section and import the ATT_MSSDK.SMSv3 namespace.
  2. Create an instance of RequestFactory with the scope type RequestFactory.ScopeTypes.SMS, as shown in the About the Cookbooks section.
  3. Invoke the Short Message Service methods using the RequestFactory instance.

Sending an SMS Message

To send an SMS message, invoke the SendSms method using the RequestFactory instance by passing the destination address (mobile number), and the message text as arguments. This method sends an SMS message to the mobile device, as shown in the following code example.

 string phonenumber = "xxxxxxxxxx";
 string message = "xxxxx";
  // If true the application expects a delivery status notification.
 // The default value is null.
 bool notifyDeliveryStatus = true;
 SmsResponse resp = this.requestFactory.SendSms(phonenumber, message, notifyDeliveryStatus);

Getting an SMS Delivery Response

To get the status of an SMS delivery request, invoke the GetSmsDeliveryResponse method using the RequestFactory instance, as shown in the following code example. This method enables applications to retrieve the status of a previously submitted SMS delivery request that was accepted by the AT&T Network for delivery to the destination mobile device. The identifier returned in the response of the corresponding call to the SendSms method must be provided as a parameter to the GetSmsDeliveryResponse method.

 string smsId = "xxxxxxxxxxxxxxx";
 SmsDeliveryResponse resp = this.requestFactory.GetSmsDeliveryResponse(smsId);

Receive SMS

When you register an application with the AT&T Developer Program at https://developer.att.com, you get a short code that identifies the application on the AT&T Mobile Network. Messages, such as SMS, that are sent to your application over the network are sent to this short code. To process these messages in your application, you must retrieve them from the platform using the application short code.

There are two different techniques for retrieving the messages sent to your application:

  • Poll for received messages and retrieve them in a batch.
  • Create a callback listener mechanism to have the messages forwarded from the platform to your application as they are received.

Polling for Messages

To poll for messages in your application, invoke the ReceiveSms method using the RequestFactory instance as shown in the following code example. This method lets you receive multiple SMS messages that were sent to your application short-code from the AT&T Mobile Network.

 string shortCode = "xxxxxxxxxxx";
 InboundSmsMessageList message = this.requestFactory.ReceiveSms(shortCode);

Receiving Messages Using a Callback Listener

To receive Mobile Originated SMS messages that were sent to your application short code instantaneously, register a callback listener application URL with the AT&T Developer Program at https://developer.att.com. The URL that you register is used by the AT&T Platform to forward the received messages to your application.

To receive SMS messages, invoke the GetSMS method using the RequestFactory class by passing a System.IO.Stream object as an argument to the method, as shown in the following code example.

 // .NET Framework Request.InputStream 
 // gets the contents of the incoming http entity body.
 System.IO.Stream stream = Request.InputStream; 
 ReceivedSMS message = RequestFactory.GetSMS(stream);

Getting the Delivery Status of a Sent SMS Message

To get the final delivery status of the SMS messages sent by your application, register a listener endpoint with the AT&T system during the application registration process or add a listener endpoint to the application profile during an update of the application. The endpoint is then associated with the short code assigned to the application. Your application must set the notifyDeliveryStatus parameter to true in the sendSms call to get delivery notifications.
*To receive SMS Delivery Status, invoke the GetSmsDeliveryStatus method using the RequestFactory class by passing a System.IO.Stream as an argument to the method, as shown in the following code example.

 // .NET Framework Request.InputStream 
 // gets the contents of the incoming http entity body.
 System.IO.Stream stream = Request.InputStream;
 SmsDeliveryStatus smsDeliveryStatus = RequestFactory.GetSmsDeliveryStatus(stream);