An open API service indexing awesome lists of open source software.

https://github.com/mjp91/mailchimp-api-wrapper

Lightweight MailChimp API wrapper
https://github.com/mjp91/mailchimp-api-wrapper

mailchimp mailchimp-api mailchimp-api-wrapper php

Last synced: 3 months ago
JSON representation

Lightweight MailChimp API wrapper

Awesome Lists containing this project

README

          

# MailChimp API Wrapper
Lightweight wrapper library for MailChimp API

## Example Usage
```php
// 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();
}
```