3

我正在使用 MCAPI.NET 与 MailChimp 交互,我需要为订阅指定分组。

        string emailAddr = "somebody@somewhere.net";
        MailChimp.MCApi mc = new MailChimp.MCApi("myapikey", true);

        var merges = new MailChimp.Types.List.Merges();
        merges.Add("FNAME", "MyFirstName");
        merges.Add("LNAME", "MyLastName");

        var group = new string[]{"PSS"};
        var grp = new MailChimp.Types.List.Grouping("Staff Type", group);
        merges.Add("Groupings", grp);

        mc.ListSubscribe("mylistid", emailAddr, merges);

我的分组没有设置好。有人可以分享一个可行的例子吗?

4

1 回答 1

2

您的代码的问题是您没有将分组列表添加到合并变量“Groupings”中。该值必须是以下类型:

MailChimp.Types.MCList<MailChimp.Types.List.Grouping>

这是一个工作副本:

var merges = new List.Merges();
var groupingList = new MailChimp.Types.MCList<MailChimp.Types.List.Grouping>();
var grouping = new MailChimp.Types.List.Grouping(myGroupId, new string[] { group1, group2 });
groupingList.Add(grouping);

merges["Groupings"] = groupingList;

// You may find it practical to include the following options, at least while testing the groupings
var options = new MailChimp.Types.List.SubscribeOptions();
options.DoubleOptIn = false;
options.ReplaceInterests = false;
options.SendWelcome = false;

mcapi.ListSubscribe(myMailChimpListId, email, merges, options);
于 2013-07-22T13:07:53.683 回答