Connection Software's SMS Developer's Toolkit

Connection Software


   Connection Software

SMS SDK v1.07

Note

This version of the documentation for Connection Software's SMS SDK refers to version 1.07 of that product. See the documentation provided with the product for the latest information.

Download

Download SMS SDK now. It's free of charge.

Contents

Using Connection Software's SMS SDK

Integrating the Connection Software Toolkit into your Visual C++ or Visual Basic application code is very easy to do. Included with this distribution are sample Microsoft Visual C++ 6 and Microsoft Visual Basic project that demonstrates how to use the DLL in your applications. It’s includes code for sending a text message, retrieving the unique message identifier assigned to that message when you send it, requesting your current credit balance and finding the approximate number of messages you have left.

When you load the demonstration application you will see several classes displayed in the Class View. The two most important are CCSoftSendSMS and CDLLDemoDlg. The first is generated from the header file CCSoftSendSMS.h which describes the interface to the DLL and the second is the handler for the dialog through which you build and send a message. Both classes will be discussed here.

Component Descriptions
Component Description
CSoftSendSMS.dll The release version of the dynamic link library. This must be on the DLL search path and is automatically loaded when your application starts up.
CSoftSendSMSD.dll The debug version of the dynamic link library. This must be on the DLL search path and is automatically loaded when your application starts up.
CSoftSendSMS.lib The release version of the stub that you need to link your application with.
CSoftSendSMSD.lib The release version of the stub that you need to link your application with.
CSoftSendSMS.h The header file which defines the class and it’s methods which you can instantiate and use in your code to send an SMS message. You will need to include this file in your source.
libeay32.dll OpenSSL library for making secure connections.
ssleay32.dll OpenSSL library for making secure connections.

 

CCSoftSendSMS

This class comes as just a header file. The dynamic library contains the actual text message sending code. It outlines the class, CCSoftSendSMS, which you need to instantiate in your code and the methods you can then call on that class.

The private member variables and methods are also included in the header but obviously cannot be accessed directly by your code. However, in most cases there are inspector and mutator methods for this purpose.

CDLLDemoDlg

The important method in this class is

void CDLLDemoDlg::OnSendButton()

This does the actually marshalling of all the dialog input control fields into a message and then sends it out.

First it instantiates the CCSoftSendSMS as sendSMS and passes the Username, PIN and ReplyTo as constructor arguments. You could construct the object without these parameters and then use the mutators setUsername, setPIN, and setReplyTo instead if it is more convenient. The important point to note is that these must be set before you try to send a message.

Also important to set before you start sending messages is any delay you want to add to the actual sending date/time. In the sample, both methods of setting the delay are supported; delay by n minutes, or delay until YYYY-MM-DDTHH:MM:SS UTC date and time. Only one should be used at a time, or the results could be unpredictable, so the sample checks whether the minutes or date/time are set. It favours minutes over date/time if both are set.

In order to be able to record any internal error’s that are generated during the sending, you should pass a FILE pointer for an open file to the class using setLogFile. If you have a command line application, you may wish to use stderr for this. Not specifying a file is valid and simply leaves logging off, but will make it harder to identify problems when you get error responses from the methods.

The actual sending of the text message is made using a very simple call to the method

CSoftReportCode submitMessageTextMessage(
const string& SendTo,
const string& TextMessage)

SendTo is the number (or numbers, comma separated) and TextMessage is the text of the message to send to those numbers. Although the method does return a result code, since the sample displays the full set of results returned from the server, it is ignored here.

Instead the following method is used, which gathers not just the report code, but also the unique message identifier assigned to the message, and also any text related to the report code.

void getLastSubmitMessageResult(
string& sMessageIdentifier,
CSoftReportCode& nReport,
string& sText)

Finally, the results are pushed back to the dialog, the log file is detached from the sendSMS object, then closed, and the method ends.

Note that this is a demonstration application and therefore has little or no validation of the data. Your own application should be more strict to avoid wasted calls to the It’s Arrived service.

HTTPS and OpenSSL

The toolkit supports secure connections using SOAP over HTTPS. The secure connection uses the free OpenSSL toolkit, for which the appropriate libraries are included in this package (libeay32.dll and ssleay32.dll).

When trying to run applications using this toolkit you will need to ensure these libraries are on the library search path. Typically these are installed in the System32 directory which is usually located under the Windows or WINNT directory on drive C:. If you are using an installer to roll out your application, for example, make sure these are installed as well as the CSoftSendSMS library.

Even if you choose not to use a secure connection, these libraries must be installed since the linker stubs in the CSoftSendSMS library will attempt to load them at start up.

CSoftSendSMS Class and Methods

The CCSoftSendSMS class is implemented in the the CSoftSendSMS DLL that comes with this package. Each method in the class is described below:

Methods

CCSoftSendSMS::CCSoftSendSMS()

CCSoftSendSMS::CCSoftSendSMS(
const string& Username,
const string& PIN)

CCSoftSendSMS::CCSoftSendSMS(
const string& Username,
const string& PIN,
const string& ReplyTo)

Constructors for the class. You can initialise the parameters which are usually static for the lifetime of the object at construction if you wish. Failure to set these, or to set them incorrectly is usually the reason for an invalid login response when calling the sendMessage… methods.

CCSoftSendSMS::~CCSoftSendSMS()

The destructor for the class.

void CCSoftSendSMS::setLogFile(FILE* fptr)

FILE* CCSoftSendSMS::getLogFile()

During the sending of a message, the class will write useful debugging information to an open FILE pointer, if you supply one. To turn off logging once you have enabled, call setLogFile((FILE *)NULL). You should always turn this off before closing the file. You can use stderr as the FILE pointer if you if you wish.

void CCSoftSendSMS::setUsername(const string& Username)

void CCSoftSendSMS::getUsername(string& Username) const

Before sending a message, you must ensure that you have set both the Username and PIN. Use these methods to set and inspect your Username.

void CCSoftSendSMS::setPIN(const string& PIN)

void CCSoftSendSMS::getPIN(string& PIN) const

Before sending a message, you must ensure that you have set both the Username and PIN. Use these methods to set and inspect your PIN.

void CCSoftSendSMS::setReplyTo(const string& ReplyTo

void CCSoftSendSMS::getReplyTo(string& ReplyTo) const

If you have purchased a Dynamic TP-OA (Originator Address) from Connection Software, you can change the originating identifier of the messages you send to this tag. If you do not own any, or only have one, then this is set by default, so there is no need to call this method. But if you have more than one tag, then you can set, or inspect it, using these methods.

void CCSoftSendSMS::setSendTime(const time_t SendTimeAbsolute)

There are two mutually exclusive ways to set the time of delivery for messages you send - using an absolute date and time or an offset in minutes. Using this method you can set a UTC date and time at which to deliver a message. The current maximum limit is three days into the future. If you set a date or time that is in the past, the message will be delivered immediately.

void CCSoftSendSMS::setSendTime(
const unsigned short SendTimeDelay)

There are two mutually exclusive ways to set the time of delivery for messages you send - using an absolute date and time or an offset in minutes. Using this method you can set a delay of SendTimeDelay minutes before delivery of the message. The maximum limit is 4320 minutes, or three days.

void setProxy(
const string& ProxyHostName,
const unsigned CSoftReportCode ProxyPortNumber,
const string& ProxyUsername,
const string& ProxyPassword,
const enum CS_PROXY_TYPE ProxyType = CS_PROXY_OFF)

void setProxyType(const enum CS_PROXY_TYPE ProxyType);

CSoftSendSMS supports HTTP and WinInet proxying if you need it. To enable proxying simply make a call to this method with the right settings for your system. When you make a call which makes an internet connection, it will then use the appropriate proxy as defined.

void setHTTP(
const enum CS_HTTP_VERSION HTTPVersion = CS_HTTP_1_0,
const enum CS_HTTP_MODE HTTPMode = CS_HTTP_INSECURE);

void setHTTPVersion(
const enum CS_HTTP_VERSION HTTPVersion);

void setHTTPMode(
const enum CS_HTTP_MODE HTTPMode);

HTTP versions 1.0 and 1.1 are supported as is HTTPS. Set the mode and version you want with these methods. Important: you will need to ensure the l SSL libraries are installed for HTTPS. These are from the OpenSSL project and should have been included with this library. They are called libeay32.dll and ssleay.dll.

CSoftReportCode CCSoftSendSMS::submitMessageTextMessage(
const string& SendTo,
const string& TextMessage)

Submits a plain gsm TextMessage for delivery to the recipient(s). SendTo may be single number, or a list of numbers separated by commas.

CSoftReportCode CCSoftSendSMS::submitMessageFlashMessage(
const string& SendTo,
const string& FlashMessage)

A flash message is the same as a standard text message (see above), except that when it is received on a phone which supports flash messages, they are displayed on the screen immediately.

CSoftReportCode CCSoftSendSMS::submitMessageRingtone(
const string& SendTo,
const string& PhoneMake,
const int LibraryNumber)

There are two ways to send ringtones. You can identify the ringtone you want from the library, using its library number (this method), or you can submit a ringtone as a raw RTTTL string (see below). The ringtone must be in the Connection Software library, otherwise you will receive an error response.

CSoftReportCode CCSoftSendSMS::submitMessageRingtone(
const string& SendTo,
const string& PhoneMake,
const string& Data)

There are two ways to send ringtones. You can identify the ringtone you want from the library, using its library number (see above), or you can submit a ringtone as a raw RTTTL string. When submitting an RTTTL string, the SendTo and PhoneMake are the same as for a library number, but the Data must be a hex encoded RTTTL string. This document does not cover the RTTTL string format or hex encoding the string.

CSoftReportCode CCSoftSendSMS::submitMessageOperatorLogo(
const string& SendTo,
const string& PhoneMake,
const int MCC,
const int MNC,
const int LibraryNumber)

Send an operator logo to the recipient, or recipients, listed in SendTo. You must specify the PhoneMake, country code (MCC), and network code (MNC), as well as the library number of the logo.

CSoftReportCode CCSoftSendSMS::submitMessageOperatorLogo(
const string& SendTo,
const string& PhoneMake,
const int MCC,
const int MNC,
const string& Data)

Send an operator logo to the recipient, or recipients, listed in SendTo. You must specify the PhoneMake, country code (MCC), and network code (MNC), as well as the hex encoded OTA bitmap of the logo (DATA).

CSoftReportCode CCSoftSendSMS::submitMessageOperatorLogo(
const string& SendTo,
const string& PhoneMake,
const int MCC,
const int MNC,
const void* Data,
const time_t DataLength)

Send an operator logo to the recipient, or recipients, listed in SendTo. You must specify the PhoneMake, country code (MCC), and network code (MNC), as well as the raw OTA bitmap of the logo (Data) and it’s length (DataLength).

CSoftReportCode CCSoftSendSMS::submitMessagePictureMessage(
const string& SendTo,
const string& PhoneMake,
const int LibraryNumber,
const string& TextMessage)

Send a picture message, with an optional text message, to the recipient, or recipients, listed in SendTo. You must supply a PhoneMake and a valid library number. If you wish to include a message, include it here, otherwise supply a blank string.

CSoftReportCode CCSoftSendSMS::submitMessagePictureMessage(
const string& SendTo,
const string& PhoneMake,
const string& Data,
const string& TextMessage)

Send a picture message, with an optional text message, to the recipient, or recipients, listed in SendTo. You must supply a PhoneMake and a hex encoded OTA bitmap. If you wish to include a message, include it here, otherwise supply a blank string.

CSoftReportCode CCSoftSendSMS::submitMessagePictureMessage(
const string& SendTo,
const string& PhoneMake,
const void* Data,
const size_t DataLength,
const string& TextMessage)

Send a picture message, with an optional text message, to the recipient, or recipients, listed in SendTo. You must supply a PhoneMake and a raw OTA bitmap binary. If you wish to include a message, include it here, otherwise supply a blank string. The DataLength must be correct for the raw Data.

CSoftReportCode CCSoftSendSMS::submitMessageGroupGraphic(
const string& SendTo,
const string& PhoneMake,
const int LibraryNumber);

Send a group graphic to the recipient, or recipients, listed in SendTo. You must supply a PhoneMake and a valid library number (see www.csoft.co.uk for details of available images).

CSoftReportCode CCSoftSendSMS::submitMessageGroupGraphic(
const string& SendTo,
const string& PhoneMake,
const string& Data)

Send a group graphic to the recipient, or recipients, listed in SendTo. You must supply a PhoneMake and a hex encoded OTA bitmap (Data).

CSoftReportCode CCSoftSendSMS::submitMessageGroupGraphic(
const string& SendTo,
const string& PhoneMake,
const void* Data,
const size_t DataLength)

Send a group graphic to the recipient, or recipients, listed in SendTo. You must supply a PhoneMake and raw OTA bitmap binary (Data). The DataLength must be correct.

void CCSoftSendSMS::getLastSubmitMessageResult(
string& MessageIdentifier,
CSoftReportCode& Report,
string& Text)

Reports the return values from the last submitMessage… call. If it was successful, the MessageIdentifier will have the unique id assigned to the message by the server, the Report will have a success code (usually -2). The Text can be ignored. If the Report is a failure code, then the MessageIdentifier should be ignored (it will be –1) but the Text may contain useful information about the error.

CSoftReportCode CCSoftSendSMS::AvailableMessages(
string& Messages)

Queries the server for the approximate number of messages left on your account.

CSoftReportCode CCSoftSendSMS::AvailableCredit(
string& Credit, string& Currency)

Queries the current credit left on your account. The amount of credit is returned aCSoftReportCode with the currency it was calculated in.

void CCSoftSendSMS::setMessageIdentifier(
const string& MessageIdentifier)

void CCSoftSendSMS::setMessageIdentifier(
const char* MessageIdentifier)

void CCSoftSendSMS::setReport(
const CSoftReportCode Report)

void CCSoftSendSMS::setText(
const string& Text)

void CCSoftSendSMS::setText(
const char* Text)

These are helper methods for the class, and are not intended for regular use, but have been declared public in case you wish to derive your own class and functionality from CCSoftSendSMS.

Parameters Table

Parameters Table
Parameter Description
Credit A numerical string of digits. The amount of credit that you currently have left in your account, to four decimal places.
Currency The currency is returned in the three letter standard ISO 4217 format (e.g. UKL for British Pounds).
Data A raw, or hex encoded, OTA bitmap, RTTTL or RTX string.
DataLength When sending a raw binary OTA bitmap or a raw RTTTL string, you must specify the length of the Data using this parameter.
FlashMessage The message is sent as a flash message, meaning it is displayed immediately it is received on the phone. There is no need to press "read". In all other ways, this is the same as a TextMessage.
HTTPMode There are two modes for the HTTP connection; Insecure HTTP (CS_HTTP_INSECURE) and secure HTTPS (CS_HTTPS_SECURE). HTTP is the default.
HTTPVersion There are two versions of HTTP supported; HTTP 1.0 (CS_HTTP_1_0) and HTTP 1.1 (CS_HTTP_1_1). HTTP 1.0 is the default.
LibraryNumber You can preview the available ringtones, picture messages, and logos at the website www.csoft.co.uk, which also contains details of how to upload your own ringtones securely and privately.
MCC / MNC Mobile Country Code. Each mobile operator has a unique MCC and MNC. When sending an Operator Logo you must quote the correct MNC and MCC for the destination phone. You can find these codes on the website www.csoft.co.uk under Worldwide Coverage.
Messages A numerical string of digits. The approximate number of messages that you currently have left in your account.
MessageIdentifier A numerical string of up to 31 digits. It is used to track each message in the It's Arrived server logs and delivery receipts. At present the Message ID is allocated by the It's Arrived server.
PhoneMake The PhoneMake must currently be one of Ericsson, Motorola, Nokia, Sagem, Sony or EMS. EMS is a catchall for EMS compatible phones. This is not case sensitive, but unknown/miss-spelt strings will generate an error.
PIN An alphanumeric string with a maximum size of 20 characters. It usually looks like 123456. The PIN is supplied (aCSoftReportCode with your Password and Username) when you subscribe to the It’s Arrived service. If you do not have an account with this service, visit www.csoft.co.uk.
ProxyHostName The dot quad address or FQDN of the proxy server.
ProxyPassword If you use authentication with HTTP proxying, this is the password that will be presented to the server.
ProxyPortNumber The port number to connect to on the proxy server.
ProxyType The type of proxying being used. HTTP (CS_PROXY_BASICHTTP), WinInet (CS_PROXY_WININET), or None (CS_PROXY_OFF).
ProxyUsername If you use authentication with HTTP proxying, this is the username that will be presented to the server.
ReplyTo If you have purchased a Dynamic TP-OA (Originator Address) from Connection Software, you can change the originating identifier of the message. If you do not own any, or only have one, then this is set by default, so there is no need to set it in your code. Attempts to use tags you do not own will be ignored.
ReportCode A numeric value that gives the server's response to the submitted message. Possible values are given on the Report Code page on the website. Defined as data type CsoftReportCode in this DLL.
SendTo The number of the mobile phone to which the message should be sent. The number may be submitted in any of the following formats: +44 77009 12345, +447700912345, 447700912345, 07700912345, 077 009 12345. If the number starts with a zero then it will be assumed to be a UK number. The format 00447700954321 (i.e. starting 00) is not legal - use either 447700954321 or 07700954321. The message can be sent to multiple recipients by separating each number with a comma e.g. 447700912345, 23412345678, 19145551234, 447700912346
SendTimeAbsolute A time_t structure that defines the absolute date and time when you wish the message to actually be sent to the recipient(s). The current maximum limit is 4320 minutes, or three days, into the future.
SendTimeDelay The number of minutes into the future to wait before delivering a message. The current maximum limit is 4320 minutes, or three days.
Text A description of the Report designed to provide more information to help in debugging. This may be blank.
TextMessage The message is a Text Message. If the message contains more than 160 characters it will be truncated. Remember than <CR> and <LF> characters are counted if sent. TextMessage should only contain valid characters, which are a subset of the Latin-1 character set. This version of the API does not support international character sets (also referred to as UTF-8, or Unicode and sometimes MBCS), but this is planned for a future revision.
Username An alphanumeric strings with a maximum size of 20 characters. It usually looks like ANOther.61234. The Username is supplied (aCSoftReportCode with your Password and PIN) when you subscribe to the It’s Arrived service. If you do not have an account with this service, visit www.csoft.co.uk.

Troubleshooting

HEAP[DLLDemo.exe]: Invalid Address specified to RtlFreeHeap(310000, 531640)

If you get this error when you run the application, then you have not compiled your application with the right run-time library Project Settings. To set the right settings;

  1. Open your application project in Visual Studio.
  2. Select the menu Project->Settings…
  3. Select the C/C++ tab
  4. Select the Category: ‘Code Generation’ from the drop down menu
  5. Ensure that the Use run-time library: drop down menu is set to ‘Multithreaded DLL’ for the Release settings and ‘Debug Multithreaded DLL’ for the Debug settings.

Unable To Locate DLL. The dyamic link library CSoftSendSMS.dll could not be found on the specified path < path list>

The CSoftSendSMS.dll file is not located aCSoftReportCode any of the dll search path’s listed. Copy the DLL from the Redist directory to one of the paths listed. For test purposes the project source directory is fine, but for application installations, it should be the system32 directory which is located under the WINNT or Windows directory, depending on the version of Windows is being used.

LINK : fatal error LNK1104: cannot open file "CSoftSendSMS.lib"

The CSoftSendSMS.lib library stub is not located aCSoftReportCode on the linker search paths so the project cannot be linked together. Copy the file from the Redist directory to your preferred directory for library files, which must also defined in the Project Settings. The source directory will usually suffice if you do not have a standard location.

DLLDemoDlg.cpp(7) : fatal error C1083: Cannot open include file: 'CSoftSendSMS.h': No such file or directory

The CSoftSendSMS.h header is not located a CSoftReportCode on the header search paths so the project cannot be compiled. Copy the file from the Redist directory to your preferred directory for header files, which must also defined in the Project Settings. The source directory will usually suffice if you do not have a standard location.

nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv

If you get errors like this, then you may not be compiling with the _AFXDLL switch set. Open your project in Visual Studio and select the menu Project and Project Settings. On the tab C/C++ choose the Category Preprocessor and ensure that _AFXDLL is in the list of Preprocessor definitions.

Support

When requesting support via email, it would greatly help us if you could state you are using CSoftSendSMS Toolkit v1.01. This will enable us to forward your request to the most appropriate person and provide you with a better service.Support is freely available via these routes;

Support
Home www.csoft.co.uk
Online Support Page: www.csoft.co.uk/cgi-bin/support_index.pl
Email: support(at)csoft.co.uk
Phone: +44 (0)20 7713 8000 (ask for Technical Support)
Fax: +44 (0)20 7713 8001 (FAO: Technical Support)

Credits

This package uses the following open source products;

gSOAP 2.2.3 by Robert van Engelen. http://www.cs.fsu.edu/~engelen/soap.html

OpenSSL 0.9.7a by OpenSSL Project. http://www.openssl.org/

gSoapWinInet by Jack Kustanowitz

Document History

Document History
Date         Author Comment
2003-02-03 MM Document created
2003-02-10 MM Added extra information about the debug and release versions of the Redist files.
2003-02-13 MM Updated with new API calls and information about SSL and Proxying. Added Credits section. Changed the name to use the phrase Toolkit not DLL, which is more descriptive.

Copyright © Connection Software 2003. All rights reserved.

SMS This page was last modified at 9:32 UTC on Wednesday April 30, 2008