A full example is also available for download.

GET Method Example

{
<div class="code">// Define values
$type = 'GET';
$returnType = 'json';
$returnTypes = array('xml' => 'text/xml', 'json' => 'application/json',
'html' => 'text/html' );
$params = array('apikey' => 'YOUR_API_KEY');$data = http_build_query($params, '', '&');

// Set up request
$ch = curl_init();
try
{
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_URL, 'http://email.api.dynect.net/rest/' .
$returnType . '/senders?' . $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array ('Accept: ' .
$returnTypes[$returnType]));
// Send request
$responseBody = curl_exec($ch);
// Get additional requestion information
$responseInfo = curl_getinfo($ch);

curl_close($ch);
}
catch (InvalidArgumentException $e)
{
curl_close($ch);
throw $e;
}
catch (Exception $e)
{
curl_close($ch);
throw $e;
}

// Display the returned value
echo '<pre>',$responseBody,'</pre>';
}

POST Method Example

{
<div class="code">// Define values
$type = 'POST';
$returnType = 'json';
$returnTypes = array('xml' => 'text/xml',
'json' => 'application/json', 'html' => 'text/html' );
$params = array('apikey' => 'YOUR_API_KEY',
'emailaddress' => 'example@domain.com');$data = http_build_query($params, '', '&');

// Set up request
$ch = curl_init();
try
{
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_URL, 'http://email.api.dynect.net/rest/' .
$returnType . '/senders');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array ('Accept: ' .
$returnTypes[$returnType]));

// Send request
$responseBody = curl_exec($ch);

// Get additional request information
$responseInfo = curl_getinfo($ch);

curl_close($ch);
}
catch (InvalidArgumentException $e)
{
curl_close($ch);
throw $e;
}
catch (Exception $e)
{
curl_close($ch);
throw $e;
}

// Display the returned value
echo '<pre>',$responseBody,'</pre>';
}