0

Am trying to create campaign/send mail to my mailchimp account so I referenced solutions found here source which works great via the code below

My issues:

Now from the mailchimp api, I did not see where to include the message body or the message content in the api. Has anyone done this. can someone help me out

here is the mailchimp API API link

$data = array("recipients" => array("list_id" => "205d96e6b4"), "type" => "regular", "settings" => array("subject_line" => "Subject", "title" => "Title", "reply_to" => "test@gmail.com", "from_name" => "Test", "folder_id" => "8888969b77"));
$data = json_encode($data);
$curl = curl_init();
curl_setopt_array($curl, array(    
   //Sample url
   CURLOPT_URL => "https://xxx.api.mailchimp.com/3.0/campaigns",
   CURLOPT_RETURNTRANSFER => true,
   CURLOPT_TIMEOUT => 30,
   CURLOPT_CUSTOMREQUEST => "POST",
   CURLOPT_POSTFIELDS => $data,
   CURLOPT_HTTPHEADER => array(
      "authorization: apikey <your_apikey>"
   ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
   $response = $err;
}
jmarkatti
  • 621
  • 8
  • 29
  • https://developer.mailchimp.com/documentation/mailchimp/reference/campaigns/content/#%20 and click on Edit. – Chris White May 13 '19 at 22:15
  • Does it mean that I have to use two API, one for sending mail and upon that I will get the campaign id to send content message via the second API that you showed me – jmarkatti May 13 '19 at 22:33

1 Answers1

0

This simple works by sending mails details via the first API is I posted above. On successful message, The campaign API is retrieved from the above result response which is then used to send message content to mailchip

jmarkatti
  • 621
  • 8
  • 29