Examples

Below are some examples to get you started. You can download the entire library with examples of all the methods. We have also detailed documentation for every method along with descriptions of the parameters.

Using the XML-RPC Library for PHP (the PEAR XML_RPC2 library).

Get Token
<?php
require_once 'XML/RPC2/Client.php';
try
{
    $client = XML_RPC2_Client::create("http://api.benchmarkemail.com/1.0/");
    $token = $client->login("YOUR BENCHMARK LOGIN", "YOUR BENCHMARK PASSWORD");
} catch (XML_RPC2_FaultException $e){
    echo "ERROR:" . $e->getFaultString() ."(" . $e->getFaultCode(). ")";
}
?>

Get Contact List
<?php
require_once 'XML/RPC2/Client.php';
try
{
    $client = XML_RPC2_Client::create("http://api.benchmarkemail.com/1.0/");
    $token = $client->login("YOUR BENCHMARK LOGIN", "YOUR BENCHMARK PASSWORD");

    $contactList = $client->listGet($token, "", 1, 10, "", "");

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

Adding Contacts to your list
<?php
require_once 'XML/RPC2/Client.php';
try
{
    $client = XML_RPC2_Client::create("http://api.benchmarkemail.com/1.0/");
    $token = $client->login("YOUR BENCHMARK LOGIN", "YOUR BENCHMARK PASSWORD");

    $listID = "999";

    $rec1['email'] = 'test1@test.com';
    $rec2['email'] = 'test2@test.com';
    $rec = array($rec1, $rec2);

    $result = $client->listAddContacts($token, $listID, $rec);
} catch (XML_RPC2_FaultException $e){
    echo "ERROR:" . $e->getFaultString() ."(" . $e->getFaultCode(). ")";
}
?>