PHP Class DrewM\MailChimp\MailChimp

Author: Drew McLellan ([email protected])
Afficher le fichier Open project: drewm/mailchimp-api Class Usage Examples

Méthodes publiques

Свойство Type Description
$verify_ssl * SSL Verification Read before disabling: http://snippets.webaware.com.au/howto/stop-turning-off-curlopt_ssl_verifypeer-and-fix-your-php-config/

Méthodes publiques

Méthode Description
__construct ( string $api_key ) Create a new instance
delete ( string $method, array $args = [], integer $timeout = 10 ) : array | false Make an HTTP DELETE request - for deleting data
get ( string $method, array $args = [], integer $timeout = 10 ) : array | false Make an HTTP GET request - for retrieving data
getLastError ( ) : array | false Get the last error returned by either the network transport, or by the API.
getLastRequest ( ) : array Get an array containing the HTTP headers and the body of the API request.
getLastResponse ( ) : array Get an array containing the HTTP headers and the body of the API response.
new_batch ( string $batch_id = null ) : Batch Create a new instance of a Batch request. Optionally with the ID of an existing batch.
patch ( string $method, array $args = [], integer $timeout = 10 ) : array | false Make an HTTP PATCH request - for performing partial updates
post ( string $method, array $args = [], integer $timeout = 10 ) : array | false Make an HTTP POST request - for creating and updating items
put ( string $method, array $args = [], integer $timeout = 10 ) : array | false Make an HTTP PUT request - for creating new items
subscriberHash ( string $email ) : string Convert an email address into a 'subscriber hash' for identifying the subscriber in a method URL
success ( ) : boolean Was the last request successful?

Private Methods

Méthode Description
attachRequestPayload ( resource &$ch, array $data ) Encode the data and attach it to the request
determineSuccess ( array $response, array | false $formattedResponse ) : boolean Check if the response was successful or a failure. If it failed, store the error.
findHTTPStatus ( array $response, array | false $formattedResponse ) : integer Find the HTTP status code from the headers or API response body
formatResponse ( array $response ) : array | false Decode the response and format any error messages for debugging
makeRequest ( string $http_verb, string $method, array $args = [], integer $timeout = 10 ) : array | false Performs the underlying HTTP request. Not very exciting.

Method Details

__construct() public méthode

Create a new instance
public __construct ( string $api_key )
$api_key string Your MailChimp API key

delete() public méthode

Make an HTTP DELETE request - for deleting data
public delete ( string $method, array $args = [], integer $timeout = 10 ) : array | false
$method string URL of the API request method
$args array Assoc array of arguments (if any)
$timeout integer Timeout limit for request in seconds
Résultat array | false Assoc array of API response, decoded from JSON

get() public méthode

Make an HTTP GET request - for retrieving data
public get ( string $method, array $args = [], integer $timeout = 10 ) : array | false
$method string URL of the API request method
$args array Assoc array of arguments (usually your data)
$timeout integer Timeout limit for request in seconds
Résultat array | false Assoc array of API response, decoded from JSON

getLastError() public méthode

If something didn't work, this should contain the string describing the problem.
public getLastError ( ) : array | false
Résultat array | false describing the error

getLastRequest() public méthode

Get an array containing the HTTP headers and the body of the API request.
public getLastRequest ( ) : array
Résultat array Assoc array

getLastResponse() public méthode

Get an array containing the HTTP headers and the body of the API response.
public getLastResponse ( ) : array
Résultat array Assoc array with keys 'headers' and 'body'

new_batch() public méthode

Create a new instance of a Batch request. Optionally with the ID of an existing batch.
public new_batch ( string $batch_id = null ) : Batch
$batch_id string Optional ID of an existing batch, if you need to check its status for example.
Résultat Batch New Batch object.

patch() public méthode

Make an HTTP PATCH request - for performing partial updates
public patch ( string $method, array $args = [], integer $timeout = 10 ) : array | false
$method string URL of the API request method
$args array Assoc array of arguments (usually your data)
$timeout integer Timeout limit for request in seconds
Résultat array | false Assoc array of API response, decoded from JSON

post() public méthode

Make an HTTP POST request - for creating and updating items
public post ( string $method, array $args = [], integer $timeout = 10 ) : array | false
$method string URL of the API request method
$args array Assoc array of arguments (usually your data)
$timeout integer Timeout limit for request in seconds
Résultat array | false Assoc array of API response, decoded from JSON

put() public méthode

Make an HTTP PUT request - for creating new items
public put ( string $method, array $args = [], integer $timeout = 10 ) : array | false
$method string URL of the API request method
$args array Assoc array of arguments (usually your data)
$timeout integer Timeout limit for request in seconds
Résultat array | false Assoc array of API response, decoded from JSON

subscriberHash() public méthode

Convert an email address into a 'subscriber hash' for identifying the subscriber in a method URL
public subscriberHash ( string $email ) : string
$email string The subscriber's email address
Résultat string Hashed version of the input

success() public méthode

Was the last request successful?
public success ( ) : boolean
Résultat boolean True for success, false for failure

Property Details

$verify_ssl public_oe property

* SSL Verification Read before disabling: http://snippets.webaware.com.au/howto/stop-turning-off-curlopt_ssl_verifypeer-and-fix-your-php-config/
public $verify_ssl