ale*_*ard 4 php mailchimp laravel mailchimp-api-v3.0
我正在尝试使用MailChimp API更新成员在我们的网络应用中更改其电子邮件时的电子邮件地址.
我正在使用Laravel MailChimp软件包,它工作得很好(我可以订阅用户,更新分组,更新名称等),但我必须有merge_vars或其他东西不正确.
我用这个:
$member_details = array(
// grabbed from config and working (also API key handled by bundle)
'id' => $id,
// passed from function - corresponds to the old email address
'email_address' => $mailchimp_old_email,
'merge_vars' => array(
// Old email again?
'EMAIL' => $mailchimp_old_email,
// new email address
'NEW-EMAIL' => $mailchimp_new_email,
),
'replace_interests' => FALSE,
);
$response = Mailchimp::listUpdateMember($member_details);
Run Code Online (Sandbox Code Playgroud)
所以"$ response = 1",这让我觉得它有效,但当我在MailChimp上查看订阅者列表时,用户电子邮件没有改变.
1.3 API文档有listSubscribe详细说明merge_vars"EMAIL"和"NEW-EMAIL",我在这篇stackoverflow帖子上读到了它.我确实尝试再次使用listSubscribe,即使它是一个现有成员,但是这个失败了,回复说该成员已经订阅了.
关于我可能出错的地方的任何建议?我还没有找到这种listUpdateMember api用法的明确例子.
事实证明答案很简单.
https://twitter.com/MailChimp_API/status/351674145609748480
在merge_vars中根本不需要NEW-EMAIL - 只需要EMAIL.
所以我的案例中的工作代码是:
$member_details = array(
// grabbed from config and working (also API key handled by bundle)
'id' => $id,
// passed from function - corresponds to the old email address
'email_address' => $mailchimp_old_email,
'merge_vars' => array(
// new email address
'EMAIL' => $mailchimp_new_email,
),
'replace_interests' => FALSE,
);
$response = Mailchimp::listUpdateMember($member_details);
Run Code Online (Sandbox Code Playgroud)
这很直接."NEW-EMAIL"之类的感觉确实不是必需的(或者应删除EMAIL,只使用"NEW-EMAIL",因为它更能描述正在发生的事情).