如何处理电子邮件已经存在mailchimp api代码php中的错误
作者:互联网
我有这个代码:
App::import('Vendor', 'mailchimp', array('file' => 'mailchimp/Mailchimp.php'));
$key = Configure::read("MAILCHIMP_KEY");
$list_id = 'xxxxxxxx';
$email=array('email' => $email_id);
$merge_vars = array(
'FNAME' => $fname,
'LNAME' => $lname,
'groupings' =>
array(
'name' => array('TestGroupTitle'),
'groups' => array('TestGroup')
)
);
$double_optin='false';
$mailchimp = new Mailchimp($key);
// sample to take help
// subscribe(string apikey, string id, struct email, struct merge_vars, string email_type, bool double_optin, bool update_existing, bool replace_interests, bool send_welcome)
$result = $mailchimp->lists->subscribe($list_id, $email, $merge_vars, 'html', $double_optin, false, true, false);
当我第一次添加我的电子邮件ID时它正常工作但如果再次添加相同的电子邮件,则会显示以下错误:xxxx@xx.com已订阅列出XXX简报.点击此处更新您的个人资料.
我没有回应任何事情,但这个信息仍然会传来.
我也知道在调试之后我得到了什么错误:
array(
'status' => 'error',
'code' => (int) 214,
'name' => 'List_AlreadySubscribed',
'error' => 'xxxx is already subscribed to list xxxx Newsletter. Click here to update your profile.'
)
我也试过这个,但什么都没发生.
if ($mailchimp->errorCode) {
$error['Code'] = $this->_mailChimp->errorCode;
$error['Message'] = $this->_mailChimp->errorMessage;
pr($error);
pr($error['Code']);
}
我正在使用PHP和Mailchimp api 2.0.任何帮助将受到高度赞赏.我浪费了这一整天的时间.
标签:php,mailchimp 来源: https://codeday.me/bug/20190529/1175994.html