truecastdesign/mailchimp

This library provides a simple MailChimp API v3 to signup people to a mailing list.

v1.0.1 2020-07-16 04:54 UTC

This package is auto-updated.

Last update: 2024-04-16 13:38:25 UTC


README

Version: v1.0.1

This library provides a simple MailChimp API v3 to signup people to a mailing list.

Install

To install with composer:

composer require truecastdesign/mailchimp

Requires PHP 7.1 or newer.

Usage

Here's a basic usage example:

Get your API key and list id from MailChimp

Status options are 'pending',

# composer autoloader
require '/path/to/vendor/autoload.php';

$MailChimp = new \Truecast\MailChimp('kl32j4kl23jklj4l23j4kl23j34-us14');

$member = ['first_name'=>'John', 'last_name'=>'Doe', 'email'=>'johndoe@gmail.com'];

try {
	$MailChimp->add($member, 'listid123456', 'pending'); # member array, list id, status
	# success
	# display a notice or take them somewhere
} catch (\Exception $ex) {
	# failed
	trigger_error("We were not able to add you to our list. Error: ".$ex->getMessage(), 256);
}