範例

下列是一些可以幫助您著手進行的範例,您可以下載整個資料庫,包含所有方法的範例,我們也有每個方法的詳細說明,附上各種參數的敘述。

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

取得代碼
<?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(). ")";
}
?>

取得聯絡人群組
<?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(). ")";
}
?>

新增聯絡人資料
<?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(). ")";
}
?>