/mailchimp-api-wrapper

Lightweight MailChimp API wrapper

Primary LanguagePHP

MailChimp API Wrapper

Lightweight wrapper library for MailChimp API

Example Usage

// construct the request handler, passing in data centre, username and API key
$requestHandler = new \MailChimp\RequestHandler("us14", "you@example.com", "abc123");

// construct the request class for the API call, passing in any required URL parameters
$subscriberGet = new ReadSubscribers("4494d94b5a");

// optionally add a request body (if required by the API)
$requestBody = array("..." => "...");
$subscriberGet->setRequestBody($requestBody);

// send the request, returns an associative array
try {
    $response = $requestHandler->handle($subscriberGet);
    // $response->getHTTPCode();
    // $response->getResponseBody();
} catch (RequestFailureException $ex) {
    // a HTTP code returned indicating failure will cause an exception
    $httpCode = $ex->getResponse()->getHttpCode();
    $response = $ex->getResponse()->getResponseBody();
}