Retrieve data from the API (XML)

OVERVIEW

The SMS Gateway is designed to allow easy retrieval of your sent items and replies.
The design allows the following:

  • Retrieval of items you have not already pulled
  • Instant retrieval of data (due to API table design and indexing)
  • Customisation to the result format
  • Prevention of timeouts

1. Sent Items

The API system uses a unique identity field called “changeid” which increments permanently. When a message status is received from the corresponding network, a new record is written to the API and the changeid will increment by 1. Messages will not be retrieved via the API that do not have any status changes.

In the result set, the element “changeid” will be present along with the other elements you have specified. This needs to be stored and the maximum changeid utilised by the next call. The following is occurring within the SMS gateway:

“Select top 100 * from API_Sent_Table where changeid > @ID order by changeid asc”

📘

Tip:

Start with id (changeid) = 0
Store the max changeid in your local system, permanently (database or IO system)
Only pull back data you require, using the “cols_returned” element (this will reduce bandwidth).

RETRIEVING SENT DATA (XML)

The function accepts 4 parameters

  • Type (String) = “sent”
  • Username (String)
  • Password (String)
  • XML (String)

Example string:
https://legacy.mymobileapi.com/api5/http5.aspx?type=sent&username=xxx&password=yyy&xmldata=yourxmlstring

The XML object looks like:

<sent>
	<settings>
		<id>0</id>
		<max_recs>100</max_recs>
		<cols_returned>sentid,eventid,numto,data</cols_returned>
		<date_format>dd/MMM/yyyy HH:mm:ss</date_format>
	</settings>
</sent>
ParameterDescriptionDefault
* IDThe max changeid from the previous call. Start with “0”-
Max_recsThe number of records returned from the call (values 1 to 100)100
Cols_returnedThe xml tags returned in the result. Options are: sentid, eventid, smstype, numto, data, customerid, status, statusdate. Each entry must be separated by a comma.ChangeID
Date FormatThe format of any dates that are returned.dd/MMM/yyyy HH:mm:ss

🚧

All entries marked with * are mandatory

2. Replies

The API system uses a unique identity field called “ReplyID” which increments permanently. When an inbound message is received from the corresponding network a new record is written to the API and hence the ReplyID will increment by 1.

In the result set the element “ReplyID” will be present along with the other elements you have specified. This needs to be stored and the maximum replyid utilized by the next call. The following is occurring with the SMS Gateway:

“Select top 100 * from API_Reply_Table where replyid > @ID order by replyid asc”

📘

Tips:

Start with id (replyid) = 0
Store the max replyid in your local system, permanently (database or IO system)
Only pull back data you require, using the “cols_returned” element (this will reduce bandwidth).

🚧

Limitations

Inbound messages are only retained for up to seven days, i.e. replies that were sent more than a week ago cannot be retrieved via Web Services.

RETRIEVING REPLIES (XML)

The function accepts 4 parameters:

  • Type (string) = “replies”
  • Username (string)
  • Password (string)
  • XML String or data set (depending on the function you choose)

Example string:
https://legacy.mymobileapi.com/api5/http5.aspx?Type=replies&username=xxx&password=yyy&xmldata=yourxmlstring

The XML object looks like:

<reply>
	<settings>
		<id>0</id>
		<max_recs>100</max_recs>
		<cols_returned>sentid,sentdata,received,sentdatetime,optout</cols_returned>
		<date_format>dd/MMM/yyyy HH:mm:ss</date_format>
	</settings>
</reply>
ParameterDescriptionDefault
* IDThe max REPLYID from the previous call-
Max_recsThe number of records returned from the call. Values 1 to 100100
Cols_returnedThe xml tags returned in the result. Options are:
replyid, eventid, numfrom, receiveddata, sentid, sentdata, sentcustomerid, received, sentdatetime. Each entry must be separated with a comma.
ReplyID
Date FormatThe format of any dates that are returned.dd/MMM/yyyy HH:mm:ss

🚧

All entries marked with * are mandatory

The output returned will be a data set or XML in the following format:

<api_result>
	<data>
		<replyid>509871807</replyid>
		<eventid>6414283881</eventid>
		<numfrom>278*******</numfrom>
		<receiveddata>Testing</receiveddata>
		<sentid>67758922377</sentid>
		<sentdata>Testing Replies</sentdata>
		<sentcustomerid/>UnqiueValue1</sentcustomerid>
		<received>19/Jan/2024 13:40:58</received>
		<sentdatetime>19/Jan/2024 13:40:49</sentdatetime>
	</data>
	<call_result>
		<result>True</result>
		<error/>
	</call_result>
</api_result>
XML tagDescription
* ReplyIDThe max unique REPLYID for each incoming message
EventIDWhen sending a single or bulk SMS, an eventid is generated. This will be returned in the result xml. This eventid can be for 1 or “infinity” message entries.
NumFromThe number of the user that sent the incoming message
ReceivedDataThe data that the user returned
SentIDThe unique sentid for the outgoing message
SentDataThe data sent to the user
SentCustomerIDThe customerid for the message when the data was sent
ReceivedThe date and time the message was received
SentDateTimeThe date and time the message was sent
StatusDateThe date and time the status was received

🚧

All entries marked with * are mandatory