MailChimp API 2.0现有电子邮件地址的错误响应

 mobiledu2502871703 发布于 2023-02-08 10:51

我试图从MailChimp获得响应以向订阅者返回消息.订阅工作正常,但我没有得到MailChimp的任何回复.我是PHP的Noob,所以我需要使用JSON,还是像我的PHP代码一样?

$MailChimp = new \drewm\MailChimp('12122338484487841-us1');
$result = $MailChimp->call('lists/subscribe', array(
        'id'                => '1123334444',
        'email'             => array('email'=>$check_mail['customers_email_address']),
        'merge_vars'        => array('FNAME'=>$check_mail['customers_firstname'], 'LNAME'=>$check_mail['customers_lastname']),
        'double_optin'      => true,
        'update_existing'   => false,
        'replace_interests' => false,
        'send_welcome'      => true,
));     

// CHECK MAILCHIMP IF EMAIL EXIST
if( $result === false ) {
    return 'You have already subscribed to the List';
}
else if( isset($result->status) && $result->status == 'error' ) {
    // Error info: $result->status, $result->code, $result->name, $result->error
}
// CHECK MAILCHIMP IF EMAIL EXIST           

谢谢

1 个回答
  • 很酷,那么你可以查一下..

    if( $result['name'] === 'List_AlreadySubscribed' ) {
        return $result['error'];// which returns "mail@example.com is already subscribed to list SyncTest. Click here to update your profile." as a string.
    }
    

    2023-02-08 10:52 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有