You are here

function MCAPI::MCAPI in Mailchimp 7

Same name and namespace in other branches
  1. 5.2 MCAPI.class.php \MCAPI::MCAPI()
  2. 5 MCAPI.class.php \MCAPI::MCAPI()
  3. 6.2 MCAPI.class.php \MCAPI::MCAPI()
  4. 6 MCAPI.class.php \MCAPI::MCAPI()

Connect to the MailChimp API for a given list. All MCAPI calls require login before functioning

Parameters

string $username_or_apikey Your MailChimp login user name OR apikey - always required:

string $password Your MailChimp login password - only required when username passed instead of API Key:

File

./MCAPI.class.php, line 39

Class

MCAPI

Code

function MCAPI($username_or_apikey, $password = null, $secure = false) {

  //do more "caching" of the uuid for those people that keep instantiating this...
  $this->secure = $secure;
  $this->apiUrl = parse_url("http://api.mailchimp.com/" . $this->version . "/?output=php");
  if (isset($GLOBALS["mc_api_key"]) && $GLOBALS["mc_api_key"] != "") {
    $this->api_key = $GLOBALS["mc_api_key"];
  }
  elseif ($username_or_apikey && !$password) {
    $this->api_key = $GLOBALS["mc_api_key"] = $username_or_apikey;
  }
  else {
    $this->api_key = $this
      ->callServer("login", array(
      "username" => $username_or_apikey,
      "password" => $password,
    ));
    $GLOBALS["mc_api_key"] = $this->api_key;
  }
}