Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mailchimp API v3.0 change subscriber email

I'd like to know if the Mailchimp API v3.0 allows for the EMAIL address to be changed for a subscriber.

This is what I have:

$email = strtolower(trim($oldEmail));
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
    return false;
}
$emailHash = md5($email);

$result = $this->patch('/lists/'.$listid.'/members/'.$emailHash, 
    array(
        'email_address' => $oldEmail,
        'merge_fields' => array("EMAIL" => $newEmail),
        'status' => "subscribed",
    ));

And it doesn't work. Mailchimp returns the usual GET MEMBER response, and shows that nothing has been changed.

Any idea?

Thank you, Riccardo

like image 581
Guerriky Avatar asked Aug 26 '15 10:08

Guerriky


People also ask

How do I add a subscriber to my Mailchimp API?

Create Mailchimp API keysGo to mailchimp select account, you will find extras dropdown. Select API keys and in the bottom left you will find a button Create A Key . Click on it and your api key is created. You have to copy the API Key under the API Key header.

What does API source mean in Mailchimp?

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.


2 Answers

I know that this is a bit late but right now the PUT method (.../3.0/lists/{listId}/members/{md5}) allows to change the email address.

I'm sending the new email in the body and MERGE0 (EMAIL) tag but using the md5 from the previous email. It is changing the email correctly.

like image 91
juanjose_hg Avatar answered Nov 05 '22 06:11

juanjose_hg


According to the docs, it does. It does not work on our side either, so we'll contact Mailchimp to know the reason why it's in the doc.

EDIT: It is indeed not possible, the documentation was outdated. Here is what mailchimp had to say about this:

Hi Philipp, ​ Thanks for reaching out to MailChimp support with those API concerns, and for allowing us to assist. ​ With MailChimp version 3.0, users cannot update a subscriber email address. While this may have been available with past versions of our API, it is no longer supported. To update a subscriber email address, the best move will be to manually update from within MailChimp. Each email address is considered to be a unique identifier for list members. ​ I can certainly understand how the documentation can be a bit misleading, and you do have the ability to update subscriber fields in the list, however email address is not one of them. This is why you have not seen that information updated in MailChimp. I will be reviewing the documentation on this end, and making suggestions to have that article edited if indeed we are suggesting that email addresses can be updated using API. Thanks for this feedback, and for hanging in with us. ​ We appreciate your time, energy and patience as we reviewed things on our end. Thank you again for choosing MailChimp, and keep us posted with any other questions that you may have moving forward. ​

like image 37
born4new Avatar answered Nov 05 '22 05:11

born4new