Updating a saved campaign

37 views
Skip to first unread message

Murray R. Summers

unread,
Dec 21, 2009, 8:55:21 AM12/21/09
to MailChimp API Discuss
I've created a campaign and saved it.  Now I want to update the MAIN content region with some new HTML.  I've tried using -

$field='html_main';
$value='<h1>some pretty NEW html content</h1>';
$retval = $api->campaignUpdate($cid, $field, $value);

and that throws an error -  Code=312 Msg=Can not update unknown option "html_main"

How should this be done?

Murray

--
Murray R. Summers
Great Web Sights
610-469-9715
msum...@great-web-sights.com
http://www.great-web-sights.com

jesse

unread,
Dec 21, 2009, 1:47:26 PM12/21/09
to MailChimp API Discuss
The field value should be "content", and the value field should be:

$value=array('html_MAIN'=>'<h1>some pretty NEW html content</h1>');


jesse


On Dec 21, 8:55 am, "Murray R. Summers" <msumm...@great-web-


sights.com> wrote:
> I've created a campaign and saved it.  Now I want to update the MAIN
> content region with some new HTML.  I've tried using -
>
> $field='html_main';
> $value='<h1>some pretty NEW html content</h1>';
> $retval = $api->campaignUpdate($cid, $field, $value);
>
> and that throws an error -  Code=312 Msg=Can not update unknown option
> "html_main"
>
> How should this be done?
>
> Murray
>
> --
> Murray R. Summers
> Great Web Sights
> 610-469-9715

> msumm...@great-web-sights.comhttp://www.great-web-sights.com 

Murray R. Summers

unread,
Dec 21, 2009, 1:51:55 PM12/21/09
to mailchimp-...@googlegroups.com
Oh boy - that is REALLY not clear.  But THANKS much for this.  Should I add a comment to the docs about it?

Thank you!

Murray

--
Murray R. Summers
Great Web Sights
610-469-9715
msum...@great-web-sights.com
http://www.great-web-sights.com



From: "jesse" <je...@mailchimp.com>
Sent: Monday, December 21, 2009 1:49 PM
To: "MailChimp API Discuss" <mailchimp-...@googlegroups.com>
Subject: Re: Updating a saved campaign


The field value should be "content", and the value field should be:

$value=array('html_MAIN'=>'

some pretty NEW html content

');


jesse



On Dec 21, 8:55 am, "Murray R. Summers" sights.com> wrote:
> I've created a campaign and saved it.  Now I want to update the MAIN
> content region with some new HTML.  I've tried using -
>
> $field='html_main';
> $value='

some pretty NEW html content

';
> $retval = $api->campaignUpdate($cid, $field, $value);
>
> and that throws an error -  Code=312 Msg=Can not update unknown option
> "html_main"
>
> How should this be done?
>
> Murray
>
> --
> Murray R. Summers
> Great Web Sights
> 610-469-9715
> msumm...@great-web-sights.comhttp://www.great-web-sights.com 

--

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.



Murray R. Summers

unread,
Dec 21, 2009, 1:55:36 PM12/21/09
to mailchimp-...@googlegroups.com
And by the way - how would I know that the field value is 'content'?  When I do campaignContent(), I don't see those field names....  What other field names are there?

jesse

unread,
Dec 21, 2009, 2:03:40 PM12/21/09
to MailChimp API Discuss
The options for campaignUpdate follow the same setup used by
campaignCreate:
http://www.mailchimp.com/api/1.2/campaigncreate.func.php

I guess I can try to make it more clear that the general options are
passed by name and the additional parameters are passed as the param
name and then normal value, though the second set of example code for
campaignUpdate does show that (absplit options). The campaignCreate
docs also list the typical names for the content sections. The names
are actually defined by the template in use as we discussed a while
ago here:
http://groups.google.com/group/mailchimp-api-discuss/browse_thread/thread/2fc50342e5a3544e


jesse

On Dec 21, 1:55 pm, "Murray R. Summers" <msumm...@great-web-


sights.com> wrote:
> And by the way - how would I know that the field value is 'content'?  When
> I do campaignContent(), I don't see those field names....  What other field
> names are there?
>
> Murray
>
> --
> Murray R. Summers
> Great Web Sights
> 610-469-9715

> msumm...@great-web-sights.comhttp://www.great-web-sights.com 
>
> ----------------------------------------


>
> From: "jesse" <je...@mailchimp.com>
> Sent: Monday, December 21, 2009 1:49 PM
> To: "MailChimp API Discuss" <mailchimp-...@googlegroups.com>
> Subject: Re: Updating a saved campaign
>
> The field value should be "content", and the value field should be:
>
> $value=array('html_MAIN'=>'
> some pretty NEW html content');
>
> jesse
>

> On Dec 21, 8:55 am, "Murray R. Summers" some pretty NEW html content';

Murray R. Summers

unread,
Dec 21, 2009, 2:08:30 PM12/21/09
to mailchimp-...@googlegroups.com
I looked at that AB split example long and hard trying to extrapolate back to my situation!  Just couldn't do it.  But now I know.... 8)

Murray

--
Murray R. Summers
Great Web Sights
610-469-9715
msum...@great-web-sights.com
http://www.great-web-sights.com



From: "jesse" <je...@mailchimp.com>
Sent: Monday, December 21, 2009 2:05 PM

To: "MailChimp API Discuss" <mailchimp-...@googlegroups.com>
Subject: Re: Updating a saved campaign

The options for campaignUpdate follow the same setup used by
campaignCreate:
http://www.mailchimp.com/api/1.2/campaigncreate.func.php

I guess I can try to make it more clear that the general options are
passed by name and the additional parameters are passed as the param
name and then normal value, though the second set of example code for
campaignUpdate does show that (absplit options). The campaignCreate
docs also list the typical names for the content sections. The names
are actually defined by the template in use as we discussed a while
ago here:
http://groups.google.com/group/mailchimp-api-discuss/browse_thread/thread/2fc50342e5a3544e


jesse

Murray R. Summers

unread,
Dec 22, 2009, 7:44:32 AM12/22/09
to mailchimp-...@googlegroups.com
I think I am still a little confused.  I have run the campaignTemplates() method on this particular template with this code -

$retval = $api->campaignTemplates();
if ($api->errorCode){
  echo "Unable to Load Templates!";
  echo "\n\tCode=".$api->errorCode;
  echo "\n\tMsg=".$api->errorMessage."\n";
  }
  else
  {
 echo "Your templates:\n"; 
 foreach($retval as $tmpl){     
   echo $tmpl['id']." - ".$tmpl['name']." - ".$tmpl['layout']."<br>\r\n";
  echo "<pre>";print_r($tmpl['sections']);echo"</pre>";
  }
 }
}

and my result is this -

Array
(
    [0] => header
    [1] => main
    [2] => sidecolumn
    [3] => footer
)

I don't see 'content' there!

I want to get this straight since I will want to programmatically alter campaign drafts and I need to know the section names to do that.

Thanks!

jesse

unread,
Dec 22, 2009, 10:49:53 AM12/22/09
to MailChimp API Discuss
That last thread I linked covered this - section names are defined per
template. Many have similar section names, but some will not.


jesse

On Dec 22, 7:44 am, "Murray R. Summers" <msumm...@great-web-

> msumm...@great-web-sights.comhttp://www.great-web-sights.com 
>
> ----------------------------------------
>


> From: "jesse" <je...@mailchimp.com>
> Sent: Monday, December 21, 2009 2:05 PM
> To: "MailChimp API Discuss" <mailchimp-...@googlegroups.com>
> Subject: Re: Updating a saved campaign
>
> The options for campaignUpdate follow the same setup used by
> campaignCreate:http://www.mailchimp.com/api/1.2/campaigncreate.func.php
>
> I guess I can try to make it more clear that the general options are
> passed by name and the additional parameters are passed as the param
> name and then normal value, though the second set of example code for
> campaignUpdate does show that (absplit options). The campaignCreate
> docs also list the typical names for the content sections. The names
> are actually defined by the template in use as we discussed a while

> ago here:http://groups.google.com/group/mailchimp-api-discuss/browse_thread/th...


> c50342e5a3544e
>
> jesse
>
> On Dec 21, 1:55 pm, "Murray R. Summers"
>
>
>

Murray R. Summers

unread,
Dec 22, 2009, 11:02:01 AM12/22/09
to mailchimp-...@googlegroups.com
Believe me, I read your last post and the associated link very carefully.  To summarize:

1.  To work correctly with the campaignUpdate() method, I had to use a field name of "content", as advised by you.. 
2.  You mentioned that these field names are given visibility by using the campaignTemplates() method.
3.  When I use the campaignTemplates() method for that particular template, I only see the field names listed below contained in the 'layout' element of the $retval array (header, main, sidecolumn, footer).  There is no mention of a field name of 'content'.

And once again, if I want to programmatically update a draft campaign that is based on a template,how do I know what field names to use for this campaignUpdate() method?  I'm not trying to be thick here! :)

Thanks,

Murray

--
Murray R. Summers
Great Web Sights
610-469-9715
msum...@great-web-sights.com
http://www.great-web-sights.com



From: "jesse" <je...@mailchimp.com>
Sent: Tuesday, December 22, 2009 10:51 AM

To: "MailChimp API Discuss" <mailchimp-...@googlegroups.com>
Subject: Re: Updating a saved campaign

That last thread I linked covered this - section names are defined per
template. Many have similar section names, but some will not.


jesse

On Dec 22, 7:44 am, "Murray R. Summers" sights.com> wrote:
> I think I am still a little confused.  I have run the campaignTemplates()
> method on this particular template with this code -
>
> $retval = $api->campaignTemplates();
> if ($api->errorCode){
>   echo "Unable to Load Templates!";
>   echo "\n\tCode=".$api->errorCode;
>   echo "\n\tMsg=".$api->errorMessage."\n";
>   }
>   else
>   {
>  echo "Your templates:\n";
>  foreach($retval as $tmpl){    
>    echo $tmpl['id']." - ".$tmpl['name']." - ".$tmpl['layout']."
\r\n";
>   echo "
";print_r($tmpl['sections']);echo"

jesse

unread,
Dec 22, 2009, 11:07:42 AM12/22/09
to MailChimp API Discuss
Maybe a short code example will clear this up:

$cid = "XXX";
$field = "content";
$value = array('html_MAIN'=>'blah, blah', 'html_HEADER'=>'blah,
blah');

$api->campaignUpdate($cid, $field, $value);

That help?


jesse

On Dec 22, 11:02 am, "Murray R. Summers" <msumm...@great-web-


sights.com> wrote:
> Believe me, I read your last post and the associated link very carefully.  
> To summarize:
>
> 1.  To work correctly with the campaignUpdate() method, I had to use a
> field name of "content", as advised by you..  
> 2.  You mentioned that these field names are given visibility by using the
> campaignTemplates() method.
> 3.  When I use the campaignTemplates() method for that particular template,
> I only see the field names listed below contained in the 'layout' element
> of the $retval array (header, main, sidecolumn, footer).  There is no
> mention of a field name of 'content'.
>
> And once again, if I want to programmatically update a draft campaign that
> is based on a template,how do I know what field names to use for this
> campaignUpdate() method?  I'm not trying to be thick here! :)
>
> Thanks,
>
> Murray
>
> --
> Murray R. Summers
> Great Web Sights
> 610-469-9715

> msumm...@great-web-sights.comhttp://www.great-web-sights.com 
>
> ----------------------------------------
>


> From: "jesse" <je...@mailchimp.com>
> Sent: Tuesday, December 22, 2009 10:51 AM
> To: "MailChimp API Discuss" <mailchimp-...@googlegroups.com>
> Subject: Re: Updating a saved campaign
>
> That last thread I linked covered this - section names are defined per
> template. Many have similar section names, but some will not.
>
> jesse
>
> On Dec 22, 7:44 am, "Murray R. Summers"

Reply all
Reply to author
Forward
0 new messages