2014-01-21 67 views
0

我试图使用MailChimp.net API将内容发送到MailChimp中的活动模板。我的模板中包含`Mailchimp.net可编辑内容的API和内容结构不显示

<b>mc:edit="question"</b>` 

而且MailChimp API希望在一个struct /关联数组JSON字符串。不过,我似乎无法得到的数据可编辑部分显示出来,我已经尝试了几种不同的方式:

 CampaignSegmentOptions segmentOptions = new CampaignSegmentOptions(); 
     segmentOptions.Match = "All"; 
     CampaignCreateContent content = new CampaignCreateContent(); 
     content.HTML = "<p>Testing</p>"; 
     CampaignCreateOptions options = new CampaignCreateOptions(); 
     options.Title = "Testing"; 
     options.ListId = listID; 
     options.ToName = "Test Name"; 
     options.FromEmail = "[email protected]"; 
     options.FromName = "Testing from Example.com"; 
     options.Subject = "Test Subject"; 
     options.FacebookComments = false; 

     //Using struct attempt 
     sections s = new sections(); 
     s.question = "What did the lion need?"; 

     //Using string attempt 
     //String[] s = new string [] {"question\":\"What did the lion need?"}; 

     //Using dictionary attempt 
     Dictionary<string,string> dict = new Dictionary<string,string>(); 
     dict.Add("question","What did the lion need?"); 

     content.Sections = dict; 
     Campaign result = mc.CreateCampaign("regular", options, content); 

有什么建议?先谢谢你。

回答

0

已解决。在我的情况下,字典的方法是唯一的工作。我发现,无论何时编辑现有的MailChimp模板,MailChimp在我保存它们并添加自己的代码后,似乎都会重新编写我的mc:edit字段,从而使我的mc:edit字段中断。但是,如果我将其模板之一导出到桌面,然后将其作为新模板导入,我发现在其网站上编辑模板不会在保存后更改我的代码。我记得在出口和进口文件中看到了一个注释,但没有任何暗示这是保持我的领域完好无损的唯一方法。