- A Mailchimp APIs extender package for PHP.
- Currently supporting the Mailchimp API v3.0.
Use the composer command below:
composer require lorddashme/php-mailchimp:v2.1.0
- Lists
- Main Class Namespace:
PHPMailChimp\Core\Modules\Lists\Facade\Lists
- Main Class Namespace:
- Members
- Main Class Namespace:
PHPMailChimp\Core\Modules\Members\Facade\Members
- Main Class Namespace:
- The
PHP MailChimp
usage are generic to all supported modules, meaning the example below will apply also to the other modules. - The
request body parameters
andrequest path parameters
structure are also the same to the mailchimp api documentation. - Recommended to check the actual mailchimp api documentation.
- The module primary class structure consist only of
request body
andrequest path
, see example below:
<?php
// Load the module class
use PHPMailChimp\Core\Modules\<Module>\Facade\<Module>;
// Initialize module class
Module::init(['apiKey' => 'abcde1234...', ...]);
// Use the default module action.
// Request Body and Request Path can be declare in two ways
// by using Closure or Array
$response = Module::create(Request Body, Request Path);
// Closure
$response = Module::create(
function($requestBody) {
return $requestBody;
},
function($requestPath){
return $requestPath;
}
);
// Array
$response = Module::create([...], [...]);
- First initialize the Lists Module Primary Class and provide the API Key.
- API Key can get in the Mailchimp Account > Extras > API Keys.
<?php
use PHPMailChimp\Core\Modules\Lists\Facade\Lists;
Lists::init(['apiKey' => 'qwxz123...']);
- After the initialization of the primary class, we can now use the default methods or action for the API.
<?php
// Closure
$response = Lists::find(
function($requestBody) {
return $requestBody;
},
function($requestPath){
$requestPath->list_id = 'a31gbd...';
return $requestPath;
}
);
// Array
$response = Lists::find([], ['list_id' => 'a31gbd...']);
<?php
// Closure
$response = Lists::create(
function($requestBody) {
$requestBody->name = 'Lists Name';
...
return $requestBody;
},
function($requestPath){
return $requestPath;
}
);
// Array
$response = Lists::create(['name' => 'Lists Name', ...], []);
<?php
// Closure
$response = Lists::update(
function($requestBody) {
$requestBody->name = 'Lists Name';
...
return $requestBody;
},
function($requestPath){
$requestPath->list_id = 'a31gbd...';
return $requestPath;
}
);
// Array
$response = Lists::update(['name' => 'Lists Name', ...], ['list_id' => 'a31gbd...']);
<?php
// Closure
$response = Lists::delete(
function($requestBody) {
return $requestBody;
},
function($requestPath){
$requestPath->list_id = 'a31gbd...';
return $requestPath;
}
);
// Array
$response = Lists::delete([], ['list_id' => 'a31gbd...']);
- If you have any question feel free to contact me: reyesjoshuaclifford@gmail.com
- or you may open an issue to this repository.