A PHP package wrapper for MailChimp API.
This package support only the version 3 of Mailchimp API.
- PHP version from 5.6.* up to latest.
- It is advice to install the package via Composer. Use the command below to install the package:
composer require lorddashme/php-mailchimp
- Below are the available functions:
- Basic usage:
<?php
include __DIR__ . '/vendor/autoload.php';
use LordDashMe\MailChimp\MailChimp;
$apiKey = 'abcde12345...';
$mailchimp = new MailChimp($apiKey);
$listId = 'qwerty12345...';
$mailchimp->post("list/{$listId}/members", function ($requestBody) {
$requestBody->email_address = 'sample_email@mailchimp.com';
return $requestBody;
});
// If you want to investigate the current request details.
$mailchimp->getRequest();
// To get the response from the MailChimp API service.
// Response: {"response_body": {...}", "header": {"response_http_code": ...}}
$response = $mailchimp->getResponse();
- Also can be done by using the below code:
<?php
include __DIR__ . '/vendor/autoload.php';
use LordDashMe\MailChimp\Facade\MailChimp;
$apiKey = 'abcde12345...';
MailChimp::init($apiKey);
$listId = 'qwerty12345...';
MailChimp::post("list/{$listId}/members", array(
'email_address' => 'sample_email@mailchimp.com'
));
MailChimp::getRequest();
// Response: {"response_body": {...}", "header": {"response_http_code": ...}}
$response = MailChimp::getResponse();
This package is open-sourced software licensed under the MIT license.