Unable to update HTML content via API

885 views
Skip to first unread message

Indy

unread,
Apr 6, 2011, 2:43:52 AM4/6/11
to MailChimp API Discuss
Hi

We are writing an integration for MailChimp. Part of what we are
trying to do is this:

1) Replicate a campaign
2) Update the title of the replicated campaign
3) Update its HTML content
4) Update its Text content

Steps 1, 2, and 4 work as expected.

Step 3 -- updating HTML content -- does not work, not matter what I
try.

This is the code we are using to accomplish this. I'd really
appreciate if anyone has any pointers.

Thanks

Indy

<?php
/**
**/
require_once 'inc/MCAPI.class.php';
require_once 'inc/config.inc.php'; //contains apikey

$api = new MCAPI($apikey);

// Update title
$field = "title";
$value = "Test Campaign - Version 1";

$retval = $api->campaignUpdate($campaignId, $field, $value);

$field = "content";

$contentArr = array();
$contentArr['html'] = '<html><body><b>Test</b></body></html>';
$contentArr['text'] = 'Test text stuff';

$retval = $api->campaignUpdate($campaignId, $field, $contentArr);

if ($api->errorCode){
echo "Unable to Update Campaign!";
echo "\n\tCode=".$api->errorCode;
echo "\n\tMsg=".$api->errorMessage."\n";
} else {
echo "SUCCESS!\n";
var_dump($retval);
}

?>

jesse

unread,
Apr 6, 2011, 11:08:12 AM4/6/11
to MailChimp API Discuss
It sounds like you are probably trying to update a campaign that is
using a template. A call to campaigns() or campaignTemplateContent()
should confirm that.


jesse

Indiver Nagpal

unread,
Apr 6, 2011, 4:47:29 PM4/6/11
to mailchimp-...@googlegroups.com
Thanks for that. Yes it is using a template.

So what would be the best approach to this?

Basically, we want to to be able to create a copy of a campaign, change its title, change html content and change text.

Would we have to go down the route of creating a brand new campaign with the settings of the old one? 

Or is there a simpler way?

--
You received this message because you are subscribed to the Google Groups "MailChimp API Discuss" group.
To post to this group, send email to mailchimp-...@googlegroups.com.
To unsubscribe from this group, send email to mailchimp-api-di...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mailchimp-api-discuss?hl=en.


jesse

unread,
Apr 7, 2011, 11:19:38 AM4/7/11
to MailChimp API Discuss
Here's some info on setting template content sections:

http://groups.google.com/group/mailchimp-api-discuss/browse_thread/thread/2fc50342e5a3544e/805a6f5d93d35fb0

Note that "fancy" template stuff like repeatables are not currently
usable.


jesse
Reply all
Reply to author
Forward
0 new messages