PHP Класс DrewM\MailChimp\MailChimp

Автор: Drew McLellan ([email protected])
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$verify_ssl * SSL Verification Read before disabling: http://snippets.webaware.com.au/howto/stop-turning-off-curlopt_ssl_verifypeer-and-fix-your-php-config/

Открытые методы

Метод Описание
__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?

Приватные методы

Метод Описание
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.

Описание методов

__construct() публичный Метод

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

delete() публичный Метод

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
Результат array | false Assoc array of API response, decoded from JSON

get() публичный Метод

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
Результат array | false Assoc array of API response, decoded from JSON

getLastError() публичный Метод

If something didn't work, this should contain the string describing the problem.
public getLastError ( ) : array | false
Результат array | false describing the error

getLastRequest() публичный Метод

Get an array containing the HTTP headers and the body of the API request.
public getLastRequest ( ) : array
Результат array Assoc array

getLastResponse() публичный Метод

Get an array containing the HTTP headers and the body of the API response.
public getLastResponse ( ) : array
Результат array Assoc array with keys 'headers' and 'body'

new_batch() публичный Метод

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.
Результат Batch New Batch object.

patch() публичный Метод

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
Результат array | false Assoc array of API response, decoded from JSON

post() публичный Метод

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
Результат array | false Assoc array of API response, decoded from JSON

put() публичный Метод

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
Результат array | false Assoc array of API response, decoded from JSON

subscriberHash() публичный Метод

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
Результат string Hashed version of the input

success() публичный Метод

Was the last request successful?
public success ( ) : boolean
Результат boolean True for success, false for failure

Описание свойств

$verify_ssl публичное свойство

* 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