【问题标题】:Add new subscriber to list in mailchimp将新订阅者添加到 mailchimp 中的列表
【发布时间】:2012-01-07 13:07:49
【问题描述】:

我想知道如何使用 asp.net 将新订阅者添加到 mailchimp 列表。

这是我在该问题中没有任何作用的代码:

var entry = new Dictionary<string, object>();
entry.Add( "FNAME", "x");
entry.Add( "LNAME", "y" );
var lsi=new listSubscribeInput(apiKey,listId,"xyz@abc.com",entry);
var ls=new listSubscribe(lsi);
ls.Execute();

【问题讨论】:

  • 最后我可以解决这个问题,它位于使用 listBatchSubscribe 的 API 附带的 PerceptiveMCAPI 文档中。

标签: c# asp.net mailchimp


【解决方案1】:

使用最新的 API (1.3),您可以使用以下方式将订阅者添加到列表中:

// Subscribe the provided email to a list. 
listSubscribe(string apikey, string id, string email_address, array merge_vars,
    string email_type, bool double_optin, bool update_existing,
    bool replace_interests, bool send_welcome);

MailChimp API

【讨论】:

  • 使用最新的 API(2.0) 这将是:subscribe(string apikey, string id, struct email, struct merge_vars, string email_type, bool double_optin, bool update_existing, bool replace_interests, bool send_welcome)跨度>
【解决方案2】:

在 C# 中,实现是这样的:

        var options = new List.SubscribeOptions{DoubleOptIn = true,EmailType = List.EmailType.Html,SendWelcome = false};
        var merges = new List<List.Merges> { new List.Merges("john@provider.com", List.EmailType.Html) { { "FNAME", "John" }, { "LNAME", "Smith" } } };
        var mcApi = new MCApi(apiKey, false);

        mcApi.ListBatchSubscribe(listId, merges, options);

【讨论】:

    【解决方案3】:

    这个解决方案对我有用。 添加到参考 MailChimp.Net.dll 比你可以定义一个像

    这样的接口
    IMailChimpManager manager = new MailChimpManager(ConfigurationManager.AppSettings["MailChimpApiKey"].ToString());
    

    您可以在 MailChimp 列表中添加或更新您的客户端

                    Member m = await manager.Members.AddOrUpdateAsync(ConfigurationManager.AppSettings["MailChimpListId"].ToString(), new Member { EmailAddress = _email, EmailType = "html", Status = Status.Pending});
                m = await manager.Members.AddOrUpdateAsync(ConfigurationManager.AppSettings["MailChimpListId"].ToString(), new Member { EmailAddress = _email, EmailType = "html", Status = Status.Subscribed });
    

    希望这会有所帮助...

    【讨论】:

      猜你喜欢
      • 2020-08-09
      • 2015-08-09
      • 2018-05-15
      • 2020-12-24
      • 2016-06-23
      • 2013-09-09
      • 2023-04-05
      • 2016-12-11
      相关资源
      最近更新 更多