如何在 mailchimp api v3 中安排活动?

How to schedule a campaign in mailchimp api v3?

我正在尝试使用 MailChimp API 的 v3 安排活动,但我在 API 文档中看不到任何执行此操作的方法。

http://developer.mailchimp.com/documentation/mailchimp/reference/overview/

有人知道 v3 上是否可以进行调度吗?

要向列表发送邮件,首先您需要创建列表和活动。

如果您已经创建了这些,您可以将带有 HTTP 请求的预定邮件发送到以下地址。

https://SERVER.api.mailchimp.com/3.0/campaigns/CAMPAIGNID/actions/schedule

SERVER:MailChimp 分配给您的服务器,您可以通过登录了解。您的仪表板 url 将类似于 https://us6.admin.mailchimp.com/

在上面的例子中,SERVERus6.

这些是 MailChimp v3 文档中请求的参数。

请求body个参数

schedule_time

  • 类型:Schedule_time
  • 标题:安排时间
  • 只读:错误

UTC 日期和时间以安排投放活动。

时间扭曲

  • 类型:布尔值
  • 标题:时间扭曲
  • 只读:错误

选择广告系列在发送时是否应使用 Timewarp。使用 Timewarp 安排的活动根据收件人的时区进行本地化。例如,schedule_time 为 13:00 的时间扭曲活动将在当地时间 1:00pm 发送给每个收件人。无法为使用批量投放的广告系列设置为 true。

batch_delivery

  • 类型:Object
  • 标题:批量交付
  • 只读:错误

选择广告系列是否应使用批量投放。不能为使用 Timewarp 的广告系列设置为 true。

晚会有点晚了,完整的 link 是 (http://developer.mailchimp.com/documentation/mailchimp/reference/campaigns/#action-post_campaigns_campaign_id_actions_schedule), also as I couldn't find complete code, here is a simple sample using (https://github.com/brandonseydel/MailChimp.Net):

public bool CampaignCreate(string campaignName, string subject, string emailText,
        string emailSender, string emailSenderName, DateTime sendTime,
        int templateID, string listID, ref string campaignID)
    {
        MailChimpManager mgr = new MailChimpManager(_apiKey);
        try
        {
            if (String.IsNullOrWhiteSpace(campaignID))
                CampaignExists(campaignName, out campaignID);

            // convert to utc and round up to nearest 15 mins
            if (sendTime.Kind != DateTimeKind.Utc)
                sendTime = sendTime.ToUniversalTime();

            sendTime = sendTime.RoundUp(TimeSpan.FromMinutes(15));

            Models.Campaign newCampaign = new Models.Campaign();
            newCampaign.Id = campaignID;
            newCampaign.Type = CampaignType.Regular;
            newCampaign.Settings = new Models.Setting();
            newCampaign.Settings.Title = campaignName;
            newCampaign.Settings.SubjectLine = subject;
            newCampaign.Recipients = new Models.Recipient();
            newCampaign.Recipients.ListId = listID;
            newCampaign.Settings.FromName = emailSenderName;
            newCampaign.Settings.ReplyTo = emailSender;
            newCampaign.Settings.TemplateId = templateID;

            newCampaign = mgr.Campaigns.AddOrUpdateAsync(newCampaign).Result;

            campaignID = newCampaign.Id;
            ContentRequest content = new ContentRequest();
            content.Html = emailText;

            mgr.Content.AddOrUpdateAsync(campaignID, content);

            mgr.Campaigns.ScheduleAsync(newCampaign.Id, new CampaignScheduleRequest()
            { ScheduleTime = sendTime.ToString("o") } );

            mgr.Campaigns.SendAsync(campaignID);

            return (!String.IsNullOrWhiteSpace(campaignID));
        }
        finally
        {
            mgr = null;
        }
    }