Mailchimp API/lists merge_fields的日期类型参数格式 [英] Mailchimp API /lists date type parameter formatting for merge_fields

查看:113
本文介绍了Mailchimp API/lists merge_fields的日期类型参数格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个date merge_field,需要在Mailchimp API的v3版本中进行填充.在我找到答案之前,很多Google都在搜索此内容……希望这可以节省一些时间.

I have a date merge_field that I need to populate in the v3 version of the Mailchimp API. Lots of google searching on this before I found my answer... hopefully this saves someone time.

推荐答案

预期格式为:mm/dd/yyyy.

看来月和日的个位数工作正常,所以不要出汗使之严格.如果您使用的是Javascript,则将日期对象传递给此函数应该对您有用(假设您可以使用本地时区):

It appears that single digits in month and day work just fine so don't sweat making it strict. If you're in Javascript passing a date object into this function should work for you (assuming you're okay with using the local timezone):

function mailchimpDateFormat(date) {
  return date.getMonth() + 1 + "/" + date.getDate() + "/" + date.getFullYear();
}

例如,在node.js中,对Mailchimp v3 API的调用如下所示:

So in node.js for example a call to the Mailchimp v3 API would look like this:

mailchimp.put({
  "path": "/lists/0564f2d799/members/c5f129f4bac9d1ca985cb58f1f45f24",
  "body": {
    "email_address": "something@company.com",
    "status": "subscribed",
    "interests": {
      "ca1564ff8f": true
    },
    "merge_fields": {
      "MY_DATE": mailchimpDateFormat(date) // e.g. "4/15/2018"
    }
  }
}, function (err, response) {
   // Do something interesting.
};

这篇关于Mailchimp API/lists merge_fields的日期类型参数格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆