How to Access the API
Authenticating a user session

All API calls require that the user be associated with an active, authenticated session. The login() function is used to authenticate the user and generate a token for the session. This token is to be used on every subsequent API call.

Token

The token is used to identify the authenticated user. You then no longer need to supply the login / password with each call. To get the list for all active tokens for a user use the getToken method. The token can be saved in any variable and be used for future references.

 

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);

    // Print the token
    echo "Your Token is :" . $token;

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

?>