You are here

function Mandrill::__construct in Mandrill 6

File

./mandrill.class.php, line 17

Class

Mandrill

Code

function __construct($api_key, $timeout = 300) {
  if (empty($api_key)) {
    throw new Mandrill_Exception('Invalid API key');
  }
  try {
    $response = $this
      ->request('users/ping', array(
      'key' => $api_key,
    ));
    if ($response != 'PONG!') {
      throw new Mandrill_Exception('Invalid API key');
    }
    $this->api = $api_key;
    $this->timeout = $timeout;
  } catch (Exception $e) {
    throw new Mandrill_Exception($e
      ->getMessage());
  }
}