mjp91/mailchimp-api-wrapper

1.1.1 2019-10-29 17:02 UTC

This package is auto-updated.

Last update: 2024-04-29 03:32:34 UTC


README

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();
}