设置Mailchimp广告系列内容html无法正常工作 [英] Setting Mailchimp campaign content html not working

查看:145
本文介绍了设置Mailchimp广告系列内容html无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用mailchimp api更新广告系列的html内容:

I tried to update my campaign html content using mailchimp api:

/campaigns/{campaign_id}/content

您可以在此处找到有关此api的更多信息: https://developer.mailchimp.com/documentation/mailchimp/reference/campaigns/content/#

You can find more information about this api here: https://developer.mailchimp.com/documentation/mailchimp/reference/campaigns/content/#

在发送广告系列之前,我尝试获取广告系列内容html,对其进行了修改,然后使用上述api设置了广告系列内容html.我只是简单地使用BeautifulSoup将新标签附加到内容主体:

Before sending a campaign, I tried to get campaign content html, modified it and then set campaign content html using above api. I just simply use BeautifulSoup to append a new tag to content body:

content.body.append(BeautifulSoup('<p>Mailchimp is freaking shittttt</p>'))

然后,发生了一些有趣的事情,我创建了第一个广告系列,效果很好,添加的标签显示在我的电子邮件中.但是,随后,子序列广告系列无法正常工作,添加的标签也没有出现.

Then, some interesting things happen, the first campaign I created, it works fine, the tag added appears in my email. But, then the sub-sequence campaigns not working anymore, the tag added not appearing.

我在mailchimp广告系列网站上观察到了一些奇怪的现象,即使我设置了广告系列的html内容,对于活动的和不起作用的广告系列,只有纯文本电子邮件(HTML Source仍然是旧版本)被更改.

I observed something strange on my mailchimp campaign site, even though I set campaign html content, only Plain-Text Email gets changed (HTML Source still the old version) for both working and not working campaign.

有人遇到过这个问题吗?

Anyone got this issue before?

推荐答案

我遇到了类似的问题,因此我不得不采取稍微不同的方法来解决它.根据此答案,由 Joel H. ,"MailChimp不允许更新广告系列的HTML内容,因为广告系列的类型基于模板.要更新HTML内容,必须将广告系列设置为自定义HTML而不是模板."

I had a similar issue and I had to take a slightly different approach to solve it. According to this answer by Joel H., "MailChimp doesn't allow updating the campaign's HTML content because the campaign type is based on a template. In order to update the HTML content, the campaign has to be set to custom HTML instead of a template."

该解决方案不适合我,但使我想到了另一种解决方案:创建模板,

That solution didn't suit me but it led me to another solution: creating a template, creating editable content areas within that template, and then using the API to retrieve and edit the text in those content areas.

这是尝试修改我的代码以解决您的问题的尝试.我正在使用Python 3和 mailchimp3 客户端.

Here is an attempt at adapting my code to solve your problem. I'm using Python 3 and the mailchimp3 client.

default_footer_content = client.templates.default_content.all(template_id=TEMPLATE_ID)['sections']['SECTION_NAME']
new_footer_content = default_footer_content.replace(PLACEHOLDER, 'Mailchimp is freaking shittttt')
client.campaigns.content.update(campaign_id=CAMPAIGN_ID, data={'template': {'id': TEMPLATE_ID, 'sections': {'SECTION_NAME': new_footer_contennt}}})

上面的代码中的一些指针:

Some pointers on the above code:

  1. 您可以使用API​​查找TEMPLATE_ID,也可以在Web界面中编辑模板时简单地通过复制URL末尾的数字来找到它
  2. 您通过在模板的适当位置放置"mc:edit ="SECTION NAME""来定义SECTION_NAME
  3. 我使用的是.replace()而不是.append(),因此您需要将PLACEHOLDER或类似内容放在模板中的适当位置

如果希望进一步说明我的答案,我希望能有所帮助.这是我对Stack Overflow的第一个答案,因此建设性的批评表示赞赏:)

I hope that helps, happy to modify my answer if it needs more clarification. This is my first answer on Stack Overflow so constructive criticism appreciated :)

这篇关于设置Mailchimp广告系列内容html无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆