How to Access the API
Filters

In case you want to retrieve records which match certain criteria, you can use filters. The filter will compare the given value to the field defined for filter in the API method to evaluate the records to return. In case the filter is set to blank, all results would be returned.

Paging

The results of the read are split into virtual pages. The number of records in each page is determined by the pageSize parameter. The pageNumber parameter determines the starting position of the records to return. The pageNumber starts from 1. For e.g. if a certain function returns 1500 records and the pageSize is set to 100, there would be 15 pages ( 1500 / 100 ) available. To retrieve records from the 1000 position, the pageNumber would have to be set to 10.

Sorting

You determine the order of the result by providing the orderBy parameter. This parameter would sort the result based on the given column. The value for the parameter would vary in different functions. By default, the result would be sorted from lowest to highest. To reverse this, you can use the sortOrder parameter. If you provide the value of "desc", the resuls would be sorted from highest to lowest.

 

Example

This example is written in PHP and requires PEAR XML-RPC installed.

<?php
/**
*
* This Example shows how to authenticate a user using XML-RPC.
* Note that we are using the PEAR XML-RPC client and recommend others do as well.
*/

require_once 'XML/RPC2/Client.php';

// Account Settings
$USERNAME = 'myusername';
$PASSWORD = 'mypassword';
$API_URL = 'http://api.benchmarkemail.com/1.0';

try
{
    // Create the XML RPC Object
    $client = XML_RPC2_Client::create($API_URL);

    // Authenticate the user
    $TOKEN = $client->login($USERNAME, $PASSWORD);

    // Fetch the first 10 Emails where the name contains "April" sorted on the last modified date,
    // recent ones appearing first
    $RECORDS = $client->emailGet($TOKEN, "April", 1, 10, "date", "1");

    print_r($RECORDS);

    // Fetch the next 10 Emails
    $RECORDS = $client->emailGet($TOKEN, "April", 2, 10, "date", "1");

    print_r($RECORDS);

} catch (XML_RPC2_FaultException $e){
    echo "ERROR:" . $e->getFaultString() ."(" . $e->getFaultCode(). ")";
}

?>