PHP code example of devlib / mailchimp-api
1. Go to this page and download the library: Download devlib/mailchimp-api 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/ */
devlib / mailchimp-api example snippets
use DevLib\API\MailChimp\MailChimp;
$apiKey = getenv('MC_API_KEY');
$list_id = getenv('MC_LIST_ID');
$api = new MailChimp($apiKey, $list_id);
use DevLib\API\MailChimp\MailChimp;
use MailChimpAPIException
$email = '[email protected]';
try{
$api->subscribe($email, [
'FNAME' => 'Emma',
'LNAME' => 'Doe'
]);
}catch(MailChimp\MailChimpAPIException $e){
echo ( 'Error: ' . $e->getMessage() );
}