Mailchimp API v3.0 更改订阅者电子邮件

Mailchimp API v3.0 change subscriber email

我想知道 Mailchimp API v3.0 是否允许为订阅者更改 EMAIL 地址。

这是我的:

$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",
    ));

而且它不起作用。 Mailchimp returns 通常的 GET MEMBER 响应,并显示没有任何更改。

有什么想法吗?

谢谢, 里卡多

不,MailChimp 确实不允许更改电子邮件地址。您可以在网络应用程序中执行此操作,但几乎所有统计信息和 activity 信息都不会保留。 API 由于这个原因,v3.0 根本不支持更改电子邮件地址。您要做的是退订或删除旧地址,然后重新创建新地址。

根据 the docs,确实如此。它在我们这边也不起作用,因此我们将联系 Mailchimp 以了解它在文档中的原因。

编辑:确实不可能,文档已经过时了。以下是 mailchimp 对此的评价:

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. ​

我知道这有点晚了,但现在 PUT 方法 (.../3.0/lists/{listId}/members/{md5}) 允许更改电子邮件地址。

我在正文和 MERGE0 (EMAIL) 标签中发送新电子邮件,但使用的是上一封电子邮件中的 md5。它正在正确更改电子邮件。

根据 MailChimps changelog 从 2016 年 11 月 3 日起可以使用 补丁 put 更改用户的电子邮件.

11/03/2016

Add the ability to update an existing list member’s email_address through a PATCH or PUT call to /lists/{list_id}/members/{subscriber_hash}

您不需要使用 merge_field 来更改电子邮件。你可以简单地这样做:

$emailHash = md5($oldEmail);

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

当然你可以更新电子邮件地址,使用

PATCH /lists/{list_id}/members/{hashed_old_email_address}

并在负载中设置新的电子邮件地址 https://mailchimp.com/developer/marketing/api/list-members/update-list-member/