2014-01-21 65 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字段中斷。但是,如果我將其模板之一導出到桌面,然後將其作爲新模板導入,我發現在其網站上編輯模板不會在保存後更改我的代碼。我記得在出口和進口文件中看到了一個註釋,但沒有任何暗示這是保持我的領域完好無損的唯一方法。