PHP code example of chimpmatic / mailchimp-subscriber
1. Go to this page and download the library: Download chimpmatic/mailchimp-subscriber library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
chimpmatic / mailchimp-subscriber example snippets
use Chimpmatic\Subscriber\Subscriber;
use Chimpmatic\Subscriber\Contact;
$subscriber = new Subscriber('your-api-key-us4');
$contact = new Contact('[email protected]', [
'FNAME' => 'John',
'LNAME' => 'Doe',
]);
$result = $subscriber->subscribe('abc123def4', $contact);
echo $result->getSummary();
// "Added [email protected] to audience abc123def4 — status: subscribed"
use Chimpmatic\Subscriber\Subscriber;
use Chimpmatic\Subscriber\Contact;
$subscriber = new Subscriber('your-api-key-us4');
$contact = new Contact('[email protected]', [
'FNAME' => 'Jane',
'LNAME' => 'Smith',
'BIRTHDAY' => '03/15',
'PHONE' => '+1-555-0100',
]);
$result = $subscriber->subscribe('abc123def4', $contact);
if ($result->isSubscribed()) {
echo "Subscribed successfully!";
}