Mailchimp API /lists date type parameter formatting for merge_fields

谁说胖子不能爱 提交于 2019-12-11 06:06:01

问题


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.


回答1:


The format expected is: mm/dd/yyyy.

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();
}

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": "4/15/2018"
    }
  }
}, function (err, response) {
   // Do something interesting.
};


来源:https://stackoverflow.com/questions/50848639/mailchimp-api-lists-date-type-parameter-formatting-for-merge-fields

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!