MailChimp API 2.0批量订阅PHP

时间:2014-05-23 11:07:13

标签: php mailchimp

我无法在MailChimp中订阅多封电子邮件。使用API​​ https://bitbucket.org/mailchimp/mailchimp-api-php/downloads

$api_key = "***";
$list_id = "***";

require ('api/Mailchimp.php');
$Mailchimp = new Mailchimp($api_key);
$Mailchimp_Lists = new Mailchimp_Lists($Mailchimp);


$batch[] = array('email' => 'user1@mail.com');
$batch[] = array('email' => 'user2@mail.com');

$subscriber = $Mailchimp_Lists -> batchSubscribe($list_id, $batch, false, false, true);

我收到以下错误:

[errors] => Array
    (
        [0] => Array
            (
                [code] => -99
                [error] => An email address must contain a single @
                [email] => user1@mail.com
            )
        [0] => Array
            (
                [code] => -99
                [error] => An email address must contain a single @
                [email] => user2@mail.com
            )

    )

1 个答案:

答案 0 :(得分:19)

电子邮件应该是结构,而不是字符串。

$batch[] = array('email' => 'user1@mail.com');
$batch[] = array('email' => 'user2@mail.com');

应该是

$batch[] = array('email' => array('email' => 'user1@mail.com'));
$batch[] = array('email' => array('email' => 'user2@mail.com'));