-1

I've successfully used the Mailchimp V3.0 API to create a new campaign and have attempted to subsequently add content to that campaign/email but I can't get it to add the content. Following is the (test) code:

$email_test_message = "Testing API v3.0";
$Content_options = array(
    'plain_text' => $email_test_message
                        );    
$json_content = json_encode($Content_options);
$auth = base64_encode('PRCadmin:' . $MAILCHIMP_API_KEY );
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $MAILCHIMP_URL_API_V3 . '/campaigns/' .   $campaign_id . '/content');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json',
        'Authorization: Basic ' . $auth));
curl_setopt($ch, CURLOPT_USERAGENT, 'PHP-MCAPI/3.0');
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POST, true);    
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_content); 
$retval = curl_exec($ch);             
$json = json_decode($retval);          
curl_close($ch);                       
Bill Ray
  • 15
  • 2
  • 7

1 Answers1

0

I can't comment to ask if you've created a custom template, but that's number one. Create a custom template (as labeled 'code your own' in MailChimp's backend).

Each entry with mc:edit has a name/id that you can target in a json array.

This post Mailchimp API not replacing mc:edit content sections (using ruby library) should provide you the direction you seek.

It's a Ruby example, but it helped me along.

Community
  • 1
  • 1
Dooley
  • 1
  • 4