public function DrupalMandrill::__construct in Mandrill 7
Same name and namespace in other branches
- 7.2 lib/mandrill.inc \DrupalMandrill::__construct()
Constructor to set internal values.
Parameters
string $api_key: Mandrill API key.
int $timeout: Server timeout.
Throws
File
- lib/
mandrill.inc, line 38 - Wrapper class around the Mandrill API.
Class
- DrupalMandrill
- Class DrupalMandrill.
Code
public function __construct($api_key, $timeout = 300) {
if (empty($api_key)) {
throw new MandrillException('Invalid API key');
}
try {
$response = $this
->request('users/ping', array(
'key' => $api_key,
));
if ($response != 'PONG!') {
throw new MandrillException('Invalid API key: ' . $response);
}
$this->api = $api_key;
$this->timeout = $timeout;
} catch (Exception $e) {
throw new MandrillException($e
->getMessage());
}
}