An open API service indexing awesome lists of open source software.

https://github.com/lorddashme/php-mailchimp

A PHP package wrapper for MailChimp API.
https://github.com/lorddashme/php-mailchimp

api mail mailchimp mailchimp-api marketing php

Last synced: about 1 year ago
JSON representation

A PHP package wrapper for MailChimp API.

Awesome Lists containing this project

README

          

# PHP MailChimp

A PHP package wrapper for MailChimp API.

This package support only the version 3 of Mailchimp API.

[![Latest Stable Version](https://img.shields.io/packagist/v/LordDashMe/php-mailchimp.svg?style=flat-square)](https://packagist.org/packages/LordDashMe/php-mailchimp) [![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg?style=flat-square)](https://php.net/) [![Coverage Status](https://img.shields.io/coveralls/LordDashMe/php-mailchimp/master.svg?style=flat-square)](https://coveralls.io/github/LordDashMe/php-mailchimp?branch=master)

## 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:

```txt
composer require lorddashme/php-mailchimp
```

## Usage

- Below are the available functions:

| Function | Description |
| -------- | ----------- |
| | |
| ```post('route', closure/array);``` | To request in the MailChimp API service using POST method. The body parameter accepts Cloure or Array type. |
| ```get('route');``` | To request in the MailChimp API service using GET method. |
| ```patch('route', closure/array);``` | To request in the MailChimp API service using PATCH method. The body parameter accepts Cloure or Array type. |
| ```delete('route');``` | To request in the MailChimp API service using DELETE method. |
| ```action('route');``` | To request in the MailChimp API service using the custom ACTION. |
| ```getRequest();``` | To check the current request details. Can be use for debugging purposes. |
| ```getRespose();``` | To get the current response from the MailChimp API service.
Response Format:
```{"response_body": {...}", "header": {"response_http_code": ...}}``` |

- Basic usage:

```php
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
'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](https://opensource.org/licenses/MIT).