<?php
//Include MailChimp API version 3 Class Library
include('mcv3/src/MailChimp.php');
use \DrewM\MailChimp\MailChimp;
$MailChimp = new MailChimp('<MAILCHIMP-API-KEY-HERE>');
//create campaign at Mailchimp
$result = $MailChimp->post('campaigns', array(
"type" => 'regular',
"recipients" => array(
"list_id" => "<LIST-ID-HERE>",
"segment_opts" => array(
"match" => "any",
"conditions" => array(
array("field" => "interests-<INTEREST-GROUP-ID-HERE>", "op" => "interestcontains", "value" => ["<INTEREST-ID-HERE>"])
),
)
),
'settings' => array(
'subject_line' => '<CAMPAIGN-SUBJECT-HERE>',
'title' => '<CAMPAIGN-NAME-HERE>',
'from_name' => '<FROM-NAME-HERE>',
'reply_to' => '<FROM-EMAIL-ID-HERE>',
'auto_footer' => false
),
'content' => array('url' => $emailerpath),
));
$campaign_id = $result['id'];
//sleep for Sometime
sleep(20);
//put content to campaign
$contentx = json_encode($MailChimp->put('/campaigns/' . $campaign_id . '/content', array('url' => $emailerpath)
));
//sleep for Sometime
sleep(20);
//send email to list
echo json_encode($MailChimp->post('/campaigns/' . $campaign_id . '/actions/send'));
?>
0 comments :