\DrewM\MailChimpMailChimp

Super-simple, minimum abstraction MailChimp API v3 wrapper MailChimp API v3: http://developer.mailchimp.com This wrapper: https://github.com/drewm/mailchimp-api

Summary

Methods
Properties
Constants
__construct()
new_batch()
subscriberHash()
getLastError()
getLastResponse()
getLastRequest()
delete()
get()
patch()
post()
put()
$verify_ssl
No constants found
No protected methods found
No protected properties found
N/A
makeRequest()
attachRequestPayload()
formatResponse()
$api_key
$api_endpoint
$last_error
$last_response
$last_request
N/A

Properties

$verify_ssl

$verify_ssl : 

Type

$api_key

$api_key : 

Type

$api_endpoint

$api_endpoint : 

Type

$last_error

$last_error : 

Type

$last_response

$last_response : 

Type

$last_request

$last_request : 

Type

Methods

__construct()

__construct(string  $api_key) 

Create a new instance

Parameters

string $api_key

Your MailChimp API key

new_batch()

new_batch(string  $batch_id = null) : \DrewM\MailChimp\Batch

Create a new instance of a Batch request. Optionally with the ID of an existing batch.

Parameters

string $batch_id

Optional ID of an existing batch, if you need to check its status for example.

Returns

\DrewM\MailChimp\Batch

New Batch object.

subscriberHash()

subscriberHash(string  $email) : string

Convert an email address into a 'subscriber hash' for identifying the subscriber in a method URL

Parameters

string $email

The subscriber's email address

Returns

string —

Hashed version of the input

getLastError()

getLastError() : array|false

Get the last error returned by either the network transport, or by the API.

If something didn't work, this should contain the string describing the problem.

Returns

array|false —

describing the error

getLastResponse()

getLastResponse() : array

Get an array containing the HTTP headers and the body of the API response.

Returns

array —

Assoc array with keys 'headers' and 'body'

getLastRequest()

getLastRequest() : array

Get an array containing the HTTP headers and the body of the API request.

Returns

array —

Assoc array

delete()

delete(string  $method, array  $args = array(), integer  $timeout = 10) : array|false

Make an HTTP DELETE request - for deleting data

Parameters

string $method

URL of the API request method

array $args

Assoc array of arguments (if any)

integer $timeout

Timeout limit for request in seconds

Returns

array|false —

Assoc array of API response, decoded from JSON

get()

get(string  $method, array  $args = array(), integer  $timeout = 10) : array|false

Make an HTTP GET request - for retrieving data

Parameters

string $method

URL of the API request method

array $args

Assoc array of arguments (usually your data)

integer $timeout

Timeout limit for request in seconds

Returns

array|false —

Assoc array of API response, decoded from JSON

patch()

patch(string  $method, array  $args = array(), integer  $timeout = 10) : array|false

Make an HTTP PATCH request - for performing partial updates

Parameters

string $method

URL of the API request method

array $args

Assoc array of arguments (usually your data)

integer $timeout

Timeout limit for request in seconds

Returns

array|false —

Assoc array of API response, decoded from JSON

post()

post(string  $method, array  $args = array(), integer  $timeout = 10) : array|false

Make an HTTP POST request - for creating and updating items

Parameters

string $method

URL of the API request method

array $args

Assoc array of arguments (usually your data)

integer $timeout

Timeout limit for request in seconds

Returns

array|false —

Assoc array of API response, decoded from JSON

put()

put(string  $method, array  $args = array(), integer  $timeout = 10) : array|false

Make an HTTP PUT request - for creating new items

Parameters

string $method

URL of the API request method

array $args

Assoc array of arguments (usually your data)

integer $timeout

Timeout limit for request in seconds

Returns

array|false —

Assoc array of API response, decoded from JSON

makeRequest()

makeRequest(string  $http_verb, string  $method, array  $args = array(),   $timeout = 10) : array|false

Performs the underlying HTTP request. Not very exciting.

Parameters

string $http_verb

The HTTP verb to use: get, post, put, patch, delete

string $method

The API method to be called

array $args

Assoc array of parameters to be passed

$timeout

Returns

array|false —

Assoc array of decoded result

attachRequestPayload()

attachRequestPayload(resource  $ch, array  $data) 

Encode the data and attach it to the request

Parameters

resource $ch

cURL session handle, used by reference

array $data

Assoc array of data to attach

formatResponse()

formatResponse(array  $response) : array|false

Decode the response and format any error messages for debugging

Parameters

array $response

The response from the curl request

Returns

array|false —

The JSON decoded into an array