gpt4 book ai didi

c# - MailChimp MCAPI.NET - 订阅分组

转载 作者:行者123 更新时间:2023-11-30 17:04:12 24 4
gpt4 key购买 nike

我正在使用 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);

我的分组没有设置好。有人有可以分享的工作示例吗?

最佳答案

您的代码存在的问题是您没有向合并变量“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);

关于c# - MailChimp MCAPI.NET - 订阅分组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17754895/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com