Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create list member with ADDRESS using Mailchimp API v3

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?

like image 540
Daniel Goetsch Avatar asked Jul 15 '16 16:07

Daniel Goetsch


People also ask

How do I add an email address to my Mailchimp list?

Click the Manage Audience drop-down and choose Add a subscriber. Type in the subscriber's information and check the This person gave me permission to email them box. Apply any necessary tags. If you have groups set up in your audience, those options will appear here.

How do I add contacts to API in Mailchimp?

To add a contact to an audience, you must include the subscription status in your payload: Use subscribed to immediately add a contact. Use pending to send a confirmation email. Once confirmed, the contact's status will update to subscribed .

What can I do with Mailchimp API?

The Mailchimp Marketing API provides programmatic access to Mailchimp data and functionality, allowing developers to build custom features to do things like sync email activity and campaign analytics with their database, manage audiences and campaigns, and more. To use the Marketing API, you need a Mailchimp account.


1 Answers

It works for me (php)

$address = new stdClass();
$address->addr1 = $customer->address;
$address->city = $customer->city;
$address->state = $customer->state;
$address->zip = $customer->zip;
$address->country = $customer->country;

$options = [
    'status' => 'subscribed',
    'email_address' => $customer->email,
    'merge_fields' => [
        'FNAME'=> $customer->first_name,
        'LNAME'=> $customer->last_name,
        'PHONE' => $customer->phone,
        'ADDRESS' => $address,
    ]
];
...
curl_setopt($ch, CURLOPT_POSTFIELDS,json_encode($options));
...
like image 97
Kammex Avatar answered Oct 18 '22 20:10

Kammex