countBatches

Counts the number of Batches that match the search criteria.

countBatches

Counts the number of Batches that match the search criteria.

Top ↑

Syntax

int countBatches( 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 Batches to be counted. See searchBatches for a description of the values that can be searched on.

Return Value

The number of Batches matching the search criteria.

Examples

The example counts the number of Batches scheduled to run after a certain time:

$search_criteria = array(
    array('send_status',  'exactly',      'pending'),
    array('is_scheduled', 'exactly',      1),
    array('send_time',    'greater_than', time()),
);

$api = new Api($url, 'YOURAPIKEY');
$sending_count = $api->invokeMethod('countBatches', $search_criteria);
{
    "id": 1,
    "method": "countBatches",
    "params": [
        "YOURAPIKEY",
        [
            [
                "send_status",
                "exactly",
                "pending"
            ],
            [
                "is_scheduled",
                "exactly",
                1
            ],
            [
                "send_time",
                "greater_than",
                1360303605
            ]
        ]
    ]
}
{
    "id": 1,
    "result": 2,
    "error": null
}

Remarks

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

See Also