简体   繁体   中英

Send a mail to list of emails via mailchimp api

I'm trying to send a list of emails via MailChimp API. I have created an API key, List, template and a campaign.

This is my code,

$MailChimp = new \DrewM\MailChimp\MailChimp(My api key);
$MailChimp->verify_ssl = false;
$campaigns = $MailChimp->get('campaigns');
$result = $MailChimp->post('campaigns/'.$campaigns['campaigns'][0]['id'].'/actions/send');

But unfortunately this command seems to be not working. I'm not getting any error message and when we dump this null response comes. I also need to pass a parameter too...

You should use the getLastError method of the MailChimp object to get the error messages of the call, once done that you will be able to understand what's wrong with your setup.

if ($MailChimp->success()) {
     print_r($result);    
 } else {
  echo $MailChimp->getLastError();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM