How to create list member with ADDRESS using Mailchimp API v3

两盒软妹~` 提交于 2019-12-23 11:56:09

问题


The ADDRESS is a Merge Field but the documentation (http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/) is not clear on how to pass it to the API, since it has sub fields for street, zip, city etc. Does anybody have an example how to do this?


回答1:


This JSON works:

{
  "addr1" : "first line",
  "addr2" : "second line",
  "city" : "city",
  "state": "state",
  "zip": "zip code",
  "country": "country"
}

It's documented in schema here: https://us1.api.mailchimp.com/schema/3.0/Lists/Members/MergeField.json




回答2:


Merge fields can pass like this:

'FNAME' => $contact->first_name,
'LNAME' => $contact->last_name,
'ADDRESS' => (Object)[
        'addr1' => $contact->fulladdress,
        //'addr2' => $contact->address2,
        'city' => $contact->city,
        'state' => $contact->state_region,
        'zip' => $contact->zip_postal_code,
        'country' => $contact->country->shortcode,
        'language' => $contact->language->code,
 ],


来源:https://stackoverflow.com/questions/38401025/how-to-create-list-member-with-address-using-mailchimp-api-v3

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