Syntax
int countMessages( string api_key [, array search_criteria ] );
Parameters
api_key
(string)The key required to access the API. See Getting Started for more information.
search_criteria
(array - optional)An array of search criteria that selects the Messages to be counted. See searchMessages for a description of the values that can be searched on.
Return Value
Returns the number of Messages that match the search criteria.
Examples
The example code finds the total number of Messages with the subjects 'Your January 2013 Newsletter is here...' or 'An Important Message from your Bank':
$search_criteria = array(
array('subject', 'exactly', 'Your January 2013 Newsletter is here...'),
'OR',
array('subject', 'exactly', 'An Important Message from your Bank')
);
$api = new Api($url, 'YOURAPIKEY');
$message_count = $api->invokeMethod('countMessages', $search_criteria);
array('subject', 'exactly', 'Your January 2013 Newsletter is here...'),
'OR',
array('subject', 'exactly', 'An Important Message from your Bank')
);
$api = new Api($url, 'YOURAPIKEY');
$message_count = $api->invokeMethod('countMessages', $search_criteria);
{
"id": 1,
"method": "countMessages",
"params": [
"YOURAPIKEY",
[
[
"subject",
"exactly",
"Your January 2013 Newsletter is here..."
],
"OR",
[
"subject",
"exactly",
"An Important Message from your Bank"
]
]
]
}
"id": 1,
"method": "countMessages",
"params": [
"YOURAPIKEY",
[
[
"subject",
"exactly",
"Your January 2013 Newsletter is here..."
],
"OR",
[
"subject",
"exactly",
"An Important Message from your Bank"
]
]
]
}
{
"id": 1,
"result": 1,
"error": null
}
"id": 1,
"result": 1,
"error": null
}
Error Codes
This method may return the following error code in addition to the standard error codes:
Code | Error | Description |
---|---|---|
311 |
Invalid Search Parameter Format | search_critera is not valid |