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://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></max_recs>
        <cols_returned></cols_returned>
        <date_format>yyyyMMddHHmmss</date_format>
    </settings>
</sent>

Parameter

Description

Default

  • ID

The max changeid from the previous call. Start with “0”

Max_recs

The number of records returned from the call (values 1 to 100)

100

Cols_returned

The 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 Format

The 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).

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://mymobileapi.com/api5/http5.aspx?Type=replies&username=xxx&password=yyy&xmldata=yourxmlstring

The XML object looks like:

<reply>
    <settings>
        <id></id>
        <max_recs></max_recs>
        <cols_returned></cols_returned>
        <date_format></date_format>
    </settings>
</reply>

Parameter

Description

Default

  • ID

The max REPLYID from the previous call

Max_recs

The number of records returned from the call. Values 1 to 100

100

Cols_returned

The 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 Format

The 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></replyid>
        <eventid></eventid>
        <numfrom></numfrom>
        <receiveddata>123</receiveddata>
        <sentid></sentid>
        <sentdata></sentdata>
        <sentcustomerid/>
        <received></received>
        <sentdatetime></sentdatetime>
    </data>
    <call_result>
        <result></result>
        <error/>
    </call_result>
</api_result>

XML tag

Description

  • ReplyID

The max unique REPLYID for each incoming message

EventID

When 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.

NumFrom

The number of the user that sent the incoming message

ReceivedData

The data that the user returned

SentID

The unique sentid for the outgoing message

SentData

The data sent to the user

SentCustomerID

The customerid for the message when the data was sent

Received

The date and time the message was received

SentDateTime

The date and time the message was sent

StatusDate

The date and time the status was received

🚧

All entries marked with * are mandatory