Tuesday, 17 July 2007

Sending MMS from the Command Line

Last time, I posted a Windows JScript file that could be used to enable the sending of OMA Client Provisioning (XML Settings) documents from a command line interface.

Pretty cool?

Well, I thought so. But it is of somewhat limited usage to the average NowSMS customer, as the volume of OMA Client Provisioning messages being sent out via NowSMS is far less than messages of other types.

What would be really useful would be to expand upon the SMS Command Line interface example to allow the sending of MMS messages from a command line interface.

So I thought the ability to post an OMA Client Provisioning document via a command line interface was a good start toward the ultimate goal of a script that could post MMS message content from a command line interface.

But I was wrong. The issue was that an OMA Client Provisioning document is a text XML document. Windows JScript has great capabilities for processing text files, but binary files are another story, so it is more challenging to post an image (GIF/JPEG) to a server via JScript.

After quite a few frustrating attempts, I realised that while it might not be possible using JScript, it could be possible using VBScript instead.

Of course, I have zero VB or VBScript experience.

But I can surf the net to find examples that I can hack like the best of them.

To submit an MMS message to NowSMS, there are several different protocols that could be used: MM7 (XML HTTP POST), MM4 (SMTP based), MM1 (HTTP based), EAIF (MM1 with additional headers), or a proprietary URL submission technique. These options are described in greater detail at http://www.nowsms.com/documentation/ProductDocumentation/mms_notifications_and_content/Submitting_MMS_Messages.htm.

I wanted to use the proprietary URL submission technique, because the encoding is a bit simpler. This is the interface that is used when you use the "Send MMS Message" web form in the NowSMS web interface. It uses "HTTP File Upload" or an HTTP POST of the "multipart/form-data" MIME type.

I found some great examples of how to perform "HTTP File Upload" submissions at http://www.motobit.com/tips/detpg_uploadvbsie/ ... and I went about to learn enough VBScript to complete this script.

The resulting code is not pretty. (Is VBScript ever?) But, it is functional.

The result is sendmms.vbs. You can right-click on the file name to download and save this file.

Assuming that the script file is saved as a file named smsmms.vbs, you would issue the following command to send an MMS message:

cscript sendmms.vbs recipient[,recipient2,recipient3...] filename [filename2] [filename3...] [variable=setting]

recipient can contain either one recipient phone number, or a comma delimited list of recipients, e.g., +44777777777,+44777777778 (important - do not include spaces)

filename is the name of a local file to be included in the MMS message. Similar to when submitting an MMS message via the "Send MMS Message" web form, you may specify multiple files that NowSMS will package up as an MMS message. (Note: NowSMS identifies content types based on the file extension of the submitted file, see the MMSCTYPE.INI file for the default list of file extension to MIME type mappings.)

variable=setting can specify additional URL parameters supported by NowSMS, such as:

  • MMSSubject=SubjectLine
  • MMSFrom=SenderAddress
  • MMSDeliveryReport=Yes
  • MMSReadReport=Yes
  • MMSPriority=High Normal Low
  • MMSMessageClass=Personal Informational Advertisement
  • MMSForwardLock=Yes
  • DRMRestrict=Yes
  • DRMRestrictTextXML=Yes
  • DRMPermissionPlay=Yes
  • DRMPermissionDisplay=Yes
  • DRMPermissionExecute=Yes
  • DRMPermissionPrint=Yes
  • DRMConstraintCount=##
  • DRMConstraintStart=yyyy-mm-dd
  • DRMConstraintEnd=yyyy-mm-dd
  • DRMConstraintInterval=##
Note: If the Subject line contains a space character, put quotes around the setting, e.g., "MMSSubject=This is a test message"

Examples:

cscript sendmms.vbs +4477777777 image.gif filename.txt "MMSSubject=This is a test message"

cscript sendmms.vbs +4477777777,+4477777778 image.gif "MMSText=This is some message text" MMSFrom=+44777777779 MMSSubject=Test

cscript sendmms.vbs +4477777777 image.gif "MMSText=The content of this message has been forward locked" "MMSSubject=Forward Lock Test" MMSForwardLock=Yes


-bn


P.S. - If you want to send an Multimedia WAP Push instead of an MMS message, include a "variable=setting" parameter of MMSWAPPush=Yes ...

Monday, 16 July 2007

Send OMA Client Provisioning (OTA XML Settings) from the Command Line

Three years ago on our discussion board we posted a simple Windows JScript that could be used to send an SMS message via NowSMS using a command-line interface. If you're not famliar with the script, then you can find more details at http://www.nowsms.com/support/bulletins/tb-nowsms-008.htm.

In the three years that have passed, I've referenced that script many times. After all, while the HTTP interface into NowSMS offers a great deal of flexibility, it is not always easy to add an HTTP interface on to an existing application. Sometimes a simple command line interface is easier to get started with ... it's easier to understand, and provides immediate feedback.

In a recent posting on the NowSMS discussion board, I was asked if there was a similar command line interface that could be used to send an OMA Client Provisioning (XML Settings) document.

I thought about all of the times that people had asked me for different variations of that script for sending different types of messages beyond the simple SMS text message ... and I thought about the wasted hours that I had spent trying to write different scripts ... frustrated by the fact that I simply was not very well versed in JScript.

Still, it sounded like a challenge worth revisiting ... and modifying the script for this purpose was actually easier than I thought it would be.

The result is sendota.js. You can right-click on the file name to download and save this file.

Assuming that the script file is saved as a file named smsota.js, you would issue the following command:

cscript sms.js PhoneNumber1[,PhoneNumber2,...] OTAFilename.xml [PINValue] [USERPIN NETWPIN]

(cscript.exe is the Windows Script Host, which is a component of Windows which should be located in the \Windows\System32 directory.)

Examples:

cscript sms.js +44777777777 settings.xml
cscript sms.js +44777777777,+44777777778 settings.xml
cscript sms.js +44777777777 settings.xml 1234
cscript sms.js +44777777777 settings.xml 1234 USERPIN

This script can be used to send XML Settings documents for any of the document types currently supported by NowSMS, including:

1.) OMA (Open Mobile Alliance) Provisioning Content (root XML element )

2.) OMA (Open Mobile Alliance) DRM Rights Objects (root XML element )

3.) WAP Push Service Indication, Service Load and Cache Operation (root XML element , or )

4.) OMA (Open Mobile Alliance) E-Mail Notification (EMN) (root XML element )

5.) Nokia/Ericsson Over The Air Settings (OTA) Specification (root XML element )

6.) Nokia/Ericssson SyncML OTA or Wireless Village Settings (root XML element or )

A "PINValue" can be associated with many of the XML settings types to provide a layer of authentication to the message. Many devices will allow you to send XML settings without a PIN, but some will require a PIN to be present before the settings will be accepted.

There are three different types of PINs, depending on the "PINType" setting.

The simplest "OTA PIN Type" is "USERPIN" (User PIN). This setting indicates that a short PIN code (often 4 digits) is supplied as the "OTA PIN". When the user receives the OTA settings message, they will need to supply this PIN code in order to be able to open the message and apply the settings. If a "PINValue" is specified, but a "PINType" is not, then USERPIN will be assumed.

"NETWPIN" (Network PIN) indicates the PIN is a network PIN code. In the GSM environment, this is the IMSI number associated with the SIM card in the device. (Hint, if you want to experiment with determining the PIN card associated with a SIM, you can put the SIM into a GSM modem and the AT+CIMI command to return the IMSI. However, not all GSM modems support the AT+CIMI command.) When the device receives the settings, if the NETWPIN does not match the IMSI, the settings will be discarded.

An additional type of PIN, known as "USERNETWPIN" also exists, which indicates a combination of the USERPIN and NETWPIN types. To use this OTA PIN type, specify the OTA PIN as the IMSI number associated with the SIM card in the device, followed by a ":" character, followed by a USERPIN (e.g., 1234567889012345:1234). When the device receives the settings, the user will be prompted for a PIN. This user supplied PIN, and the SIM card IMSI, must match in order for the settings to be accepted.

-bn

P.S. - Now the real challenge ... can I hack this script further to create a script that can easily send MMS messages from the command line, uploading local content objects from the script? Stay tuned ....

Friday, 13 July 2007

Multiple Modems for Sending Outbound MMS

File this as a "not so obvious" configuration feature of NowSMS....

When you are sending MMS messages via an operator MMSC using a GRPS(/EDGE/UMTS/WCDMA) modem, NowSMS only allows you to designate one of the modems as the "Default Route" for outbound MMS message routing.

So, if you have multiple modems installed, all messages are sent via only one of the modems, unless you define prefix mappings to route different phone number prefixes to different modems.

A frequently asked question is, how do you configure multiple default routes so that messages can be simultaneously routed via multiple modems?

The answer is to edit the individual routing definitions for each modem, and put "*" in the "Route messages to this account for recipient phone number(s)" field. This setting works the same as designating a route as the "Default Route" (and takes precedence over the actual "Default Route" setting).

Note that some versions of NowSMS may display a warning message: "To specify this route as the default outbound route for MMS message delivery, please select this route as the 'Default Route' on the next dialog." However, you can ignore this warning. (The reason for this warning is that very old versions of NowSMS did not have the "Default Route" option, the only way to set a default route was to put a "*" in the "Route messages..." field. The "Default Route" setting was easier for people to understand, but we kept the routing logic in place to support the "*" setting as well.)