lorddashme / php-mailchimp
A PHP package wrapper for MailChimp API.
3.1.0
2018-09-27 10:52 UTC
Requires
- php: >=5.6 || >=7.0 || >=7.1 || >=7.2
- lorddashme/php-static-class-interface: 1.*
Requires (Dev)
- mockery/mockery: 1.*
- phpunit/phpunit: 5.* || 6.* || 7.*
README
A PHP package wrapper for MailChimp API.
This package support only the version 3 of Mailchimp API.
Requirement(s)
- PHP version from 5.6.* up to latest.
Install
- It is advice to install the package via Composer. Use the command below to install the package:
composer require lorddashme/php-mailchimp
Usage
- 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();
License
This package is open-sourced software licensed under the MIT license.