1. Go to this page and download the library: Download skovmand/mailchimp-laravel 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/ */
skovmand / mailchimp-laravel example snippets
class NewsletterManager
{
protected $mailchimp;
protected $listId = '1234567890'; // Id of newsletter list
/**
* Pull the Mailchimp-instance from the IoC-container.
*/
public function __construct(\Mailchimp $mailchimp)
{
$this->mailchimp = $mailchimp;
}
/**
* Access the mailchimp lists API
*/
public function addEmailToList($email)
{
try {
$this->mailchimp
->lists
->subscribe(
$this->listId,
['email' => $email]
);
} catch (\Mailchimp_List_AlreadySubscribed $e) {
// do something
} catch (\Mailchimp_Error $e) {
// do something
}
}
}