You are here

function mandrill_get_api_object in Mandrill 6

Same name and namespace in other branches
  1. 8 mandrill.module \mandrill_get_api_object()
  2. 7.2 mandrill.module \mandrill_get_api_object()
  3. 7 mandrill.module \mandrill_get_api_object()

Factory method to get a Mandrill API object for communication with the mailchimp server.

Parameters

bool $reset: Pass in TRUE to reset the statically cached object.

Return value

mixed Mandrill Object upon success FALSE if variable_get('mandrill_api_key') is unset

Throws

Mandrill_Exception

2 calls to mandrill_get_api_object()
MandrillMailSystem::mail in ./mandrill.mail.inc
Send the email message.
mandrill_get_tags in ./mandrill.module
Get all available MailChimp STS tags

File

./mandrill.module, line 122
Enables Drupal to send email directly through MailChimp STS.

Code

function mandrill_get_api_object($reset = FALSE) {
  static $api = NULL;
  if ($api === NULL || $reset == TRUE) {
    $api_key = variable_get('mandrill_api_key', '');
    $api_timeout = variable_get('mandrill_api_timeout', 60);
    if (empty($api_key)) {
      return FALSE;
    }
    require_once 'mandrill.class.php';
    $api = new Mandrill($api_key, $api_timeout);
  }
  return $api;
}