PHP code example of sreedev / laravel-mailchimp
1. Go to this page and download the library: Download sreedev/laravel-mailchimp 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/ */
sreedev / laravel-mailchimp example snippets
composer
use Sreedev\MailChimp\Facades\MailChimp;
$result = MailChimp::get('lists');
print_r($result);
$list_id = 'b1234346';
$result = MailChimp::post("lists/$list_id/members", [
'email_address' => '[email protected] ',
'status' => 'subscribed',
]);
print_r($result);
$list_id = 'b1234346';
$subscriber_hash = MailChimp::subscriberHash('[email protected] ');
$result = MailChimp::patch("lists/$list_id/members/$subscriber_hash", [
'merge_fields' => ['FNAME'=>'First', 'LNAME'=>'Man'],
'interests' => ['2s3a384h' => true],
]);
print_r($result);
$list_id = 'b1234346';
$subscriber_hash = MailChimp::subscriberHash('[email protected] ');
MailChimp::delete("lists/$list_id/members/$subscriber_hash");
$list_id = 'b1234346';
$result = MailChimp::post("lists/$list_id/members", [
'email_address' => '[email protected] ',
'status' => 'subscribed',
]);
if (MailChimp::success()) {
print_r($result);
} else {
echo MailChimp::getLastError();
}
use Sreedev\MailChimp\Facades\MailChimp;
$Batch = MailChimp::newBatch()
$list_id ="abcd";
$Batch->post("op1", "lists/$list_id/members", [
'email_address' => '[email protected] ',
'status' => 'subscribed',
]);
$Batch->post("op2", "lists/$list_id/members", [
'email_address' => '[email protected] ',
'status' => 'subscribed',
]);
$Batch->post("op3", "lists/$list_id/members", [
'email_address' => '[email protected] ',
'status' => 'subscribed',
]);
$result = $Batch->process();
MailChimp::newBatch($batchId);
$result = $Batch->checkStatus();
echo MailChimp::getLastError();
print_r(MailChimp::getLastResponse());
print_r(MailChimp::getLastRequest());