Mailchimp API not replacing mc:edit content sections (using ruby library)
I struggled with this for a few days, using the template manager in MailChimp. The only way I got it to work was exporting my existing template, adding the mc:edit tag to the code and then uploading it as a custom template.
Exporting template from MailChimp
- Go to 'Templates'
- Click on the 'Edit' drop down arrow, next to the template you want to use with the API
- Select 'Export HTML'
Uploading your template to MailChimp
- Go to 'Templates'
- Click the 'Create Template ' button in the top right
- Click the 'Code Your Own'
- Then select 'Import html'
Example of my template code:
<div mc:edit="eventmessage">
Custom Event Message (replaced by API Call)
<br></div>
As a check, I was now able to see the section now appear when using /templates/info API call
Once I confirmed that Mailchimp saw the template section I used /campaigns/create call, as mentioned above but skipping over the html definition.
Updated campaign/create (content/sections):
},
"content": {
"sections": {
"eventmessage": "Event Message Content"
},
},
How to set editable image in MailChimp template via API
Unfortunately editable content areas are not supported in the MailChimp API. The editable area was made for use within their own editors.
A workaround is to just have an editable content area and to put a full image tag into it via the API.
For example;
content: {
sections: {
header_image: "<img src='http://somewhere.com/foo.jpg'>",
header: "Our latest newsletter",
body: "<p>My fabulous content</p>",
... other named mc:edit section content ...
}
}
mailchimp API 3.0, template html source
I just answered this question over here - mailchimp 3.0 Get template in html form
There's no direct way of getting the source of a template (yet), but you can create a campaign with your templates and then get the source of that campaign.
http://developer.mailchimp.com/documentation/mailchimp/reference/campaigns/content/
Looking to give MailChimp dynamic content?
If looking to inject custom content into a template at the time of sending, I would recommend having a look into creating a custom template that uses our template language.
If you've created a custom template within MailChimp using our template language to specify editable content areas: http://templates.mailchimp.com/getting-started/template-language/, then you would be able to update those content areas via the API.
To do this, you'll want to make either a campaigns/create call: https://apidocs.mailchimp.com/api/2.0/campaigns/create.php or a campaigns/update call: https://apidocs.mailchimp.com/api/2.0/campaigns/update.php and specify the section and content that you'd like to change as part of the 'content' parameter. the content 'sections' will correspond to the mc:edit tags that were added to the custom template.
You also have the ability to customize your content, like adding a first name to a greeting in the body of your content for instance, even further with the use of merge tags. I highly recommend checking those out as well and consider using them in your content if you need that level of customization: Getting Started with Merge Tags: http://kb.mailchimp.com/merge-tags/using/getting-started-with-merge-tags
What's going on with this class constructor function in the PHP MailChimp API wrapper?
The Mailchimp part is the kind of object expected to be passed to the constructor.
This is called type hinting. See this link for more info:
http://php.net/manual/en/language.oop5.typehinting.php
Creating a List in mail chimp
It was not possible in the API 1.3. I assume the same restriction applies to the new version 2.0 as well.
It's not possible through the API.
It would probably open way too many doors for abusers.
Just make as many lists as you need from within the web-app. (and look at using groups to structure your list data instead)
Related Topics
Rails 5 Db Migration: How to Fix Activerecord::Concurrentmigrationerror
Installing Rmagick Gem -- Can't Find Magickwand.H
Bootstrap Datepicker Default Value Simple_Form_For
How Can Bundler/Gemfile Be Configured to Use Different Gem Sources During Development
Possible to Use Stylesheet.Css.Erb in Rails
Working with Decimals in Ruby on Rails 3
Rails 3, Displaying Jpg Images from the Local File System Above Rails_Root
New to Ruby - While Loop Issues in Irb
How to Force a Cucumber Scenario to Fail
How to Reset a Factory_Girl Sequence
Ruby Variable Name with Double Underscores
How to Has_And_Belongs_To_Many Multiple Instances of the Same Model
Skip/Disable Force_Ssl for Particular Controller in Rails
Error Using PHPstorm's SASS File Watcher
When Do You Need a Require in a Rails Gemfile
Erroneous "Insecure World Writable Dir Foo in Path" When Running Ruby Script