Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

 

Retrieve an individual delivery report (or combined reports), which shows the current known status of messages sent in a given time period, or for a particular campaign orcampaigns.

Conversely, the function getDeliveryReports gets a list of available delivery report names, including delivery reports for campaigns.

Tip

Messages sent with the API can be given a 'tag'. The getDeliveryReport function allows you to specify that tag in order to restrict your search.


See also What is a sent message?

To get the contents of a delivery report for the campaign name 'mycampaign-020411':

Code Block
themeRDark
languagephp
titleExample
linenumberstrue
$result = $tmClient->getDeliveryReport('mycampaign-020411');

To get the delivery report details for 'mycampaign-020411' between 01:00 and 02:00 on 1st Jan 2011:

Code Block
themeRDark
languagephp
titleExample
linenumberstrue
$result = $tmClient->getDeliveryReport('mycampaign-020411', '2011-01-01T01:00:00+00:00', '2011-01-01T02:00:00+00:00');

Or, between 01:00 on 1st Jan 2011 and now:

Code Block
themeRDark
languagephp
titleExample
linenumberstrue
$result = $tmClient->getDeliveryReport('mycampaign-020411', '2011-01-01T01:00:00+00:00', time());

To get delivery report details for all campaigns and API sends between the same dates as the previous 2 examples:

Code Block
themeRDark
languagephp
titleExample
linenumberstrue
$result = $tmClient->getDeliveryReport('all', '2011-01-01T01:00:00+00:00', 
'2011-01-01T02:00:00+00:00');
$result = $tmClient->getDeliveryReport('all', '2011-01-01T01:00:00+00:00', time());

To get a delivery report with the name 'mycampaign-020411', restricted to those messages sent with custom tag 'test':

Code Block
themeRDark
languagephp
titleExample
linenumberstrue
 $result = $tmClient->getDeliveryReport('mycampaign-020411', null, null, 'test');

To get the status of messages from all delivery reports for messages sent with custom tag 'test':

Code Block
themeRDark
languagephp
titleExample
linenumberstrue
 $result = $tmClient->getDeliveryReport('all', null, null, 'test');

The same as the previous 2 examples, but between 2 dates:

Code Block
themeRDark
languagephp
titleExample
linenumberstrue
 $result = $tmClient->getDeliveryReport('mycampaign-020411', '2011-01-01T01:00:00+00:00', 
'2011-01-01T02:00:00+00:00', 'test');
$result = $tmClient->getDeliveryReport('all', '2011-01-01T01:00:00+00:00', time(), 'test');

A complete example, including output:

Code Block
themeRDark
languagephp
titleExample
linenumberstrue
$result = $tmClient->getDeliveryReport('all');
foreach ($result as $key => $report)
{
	echo "Report number $key: Name {$report['name']}, Last Updated {$report['last_updated']} <br/>\n";
foreach ($report['reportrow'] as $key => $reportrow){
	echo "Message ID: {$reportrow['message_id']}, number:{$reportrow['mobile_number']}, 
Status:{$reportrow['status']}, Updated:{$reportrow['last_updated']}<br/>\n";
	}
}

Arguments:

 

string $name: 

name of the delivery report to retrieve or 'all' to retrieve all campaign/API report data.

string/int $date_start:

(optional) restrict search to be from $date_start (Europe/London time). String dates should be in ISO 8601 format. Integer dates as Unix timestamp.

string/int $date_end:

(optional) restrict search to be up to $date_end (Europe/London time). String dates should be in ISO 8601 format. Integer dates as Unix timestamp.

string $custom: 

(optional) restrict search to those SMS sent with a custom 'tag' (see custom parameter of sendSms function). Up to and including 20, alpha-numeric characters.

Returns:

an array of arrays. Each nested array represents a delivery report and has 4 keys: 'name', 'last_updated', 'extension' and 'reportrow':

Array key 

Value

name

String. The name of the delivery report containing the message statuses. For campaigns sent via the web interface, this is the campaign name that way specified.
For messages sent via one of our APIs, the name is GatewayAPI_DD-MM-YY, where DD is the calendar day, MM the month, and YY the year.

last_updated 

String. The last time a message delivery status in this delivery report was updated, ISO 8601 format. This allows you to determine whether there was a change since you last accessed the report.

extension 

DEPRECATED – this value no longer has any meaning.

reportrowArray. reportrow is an array with keys 'message_id', 'mobile_number','status' and 'last_updated' (see below).

reportrow is an array with 4 keys:

Array key

Value

message_id 

String. The unique ID of the sent message (different for each number sent to).

mobile_number

String. The mobile number that the message was sent to, in international format, e.g. 447000000000.

status

String. The status of the message delivery.

PENDING means the status of the sent message is currently unknown.
REJECTED means that the relevant operator rejected the message and did not attempt to deliver it.
FAILED probably means that the number doesn't exist (or not anymore), or the recipient didn't turn on their phone to receive the message and it expired.
DELIVERED means the message was received on the handset.NON-UK means you are on a UK-only account and have tried to send a non-UK number

last_updated 

String. The last time this message delivery status was updated, ISO8601 format. This allows you to determine whether there has been a change since you last accessed the report.

Specific error codes:

CodeMeaning
0The custom value must contain only alpha-numeric characters
1

The custom value must be between 1 and 20 characters in length

2

The 'from' and 'to' timestamps must be in ISO 8601 format

Note

error code 404 is reported if no delivery reports are found using the specified search criteria. See General error codes.

 

Panel
title
  • Next
Panel
titleAll Functions
Panel
titleDownload

 

 

Warning
titleYou must know!

Our example code is an illustration of how you might integrate with our systems and is not certified for production environments. You are responsible for testing and QA.