如何获取每个列表订阅状态的Mailchimp会员信息?

时间:2013-09-23 12:53:30

标签: php mailchimp

如何获取每个列表订阅状态的Mailchimp会员信息?

$mailChimp = new MCAPI($this->api_key);
$listid = 'xxxxxxxxxx';
$retval = $mailChimp->listMemberInfo( $listid, 'yourname@gmail.com' );

if ($this->_mailChimp->errorCode) {
   $error['Code'] = $this->_mailChimp->errorCode;
   $error['Message'] = $this->_mailChimp->errorMessage;
   return $error;
}

print_r($retval);

返回数组:

Array
(
    [id]        => xxxxxxxxxx
    [email]     => yourname@gmail.com
    [email_type]=> html
    [ip_opt]    => xxx.xxx.xxx.xxx
    [ip_signup] => 
    [member_rating] => 2
    [info_changed] => 2013-09-23 12:08:28
    [web_id]    => xxxxxxxx
    [merges]    => Array
        (
            [EMAIL]  => yourname@gmail.com
            [MERGE0] => yourname@gmail.com
            [FNAME]  => Firstname
            [MERGE1] => Firstname
            [LNAME]  => Lastname
            [MERGE2] => Lastname
        )

    [status]    => unsubscribed
    [timestamp] => 2013-09-23 12:08:28
    [lists]     => Array
        (
            [xxxxxxxxxx] => subscribed
            [xxxxxxxxxx] => subscribed
            [xxxxxxxxxx] => subscribed
        )
)

但在这里我不知道如何检查我订阅了哪个List以及哪个是Unsubscribed。因为

[lists]     => Array
    (
        [xxxxxxxxxx] => subscribed
        [xxxxxxxxxx] => subscribed
        [xxxxxxxxxx] => subscribed
    )

此处所有列表与使用

的原始列表ID获取列表不匹配 Mailchimp的

lists()方法

$retval = $mailChimp->lists();

任何人都知道如何检查my email id: 'yourname@gmail.com'是否已订阅此列表并取消订阅此列表。

我想知道给定List_ID and Email_ID

的每个列表的状态
  

我使用PHP作为技术。

1 个答案:

答案 0 :(得分:1)

我意识到这是一个老问题,但对于未来的访问者:

对于API的第2版(Mailchimp类有public $root = 'https://api.mailchimp.com/2.0';),这对我有用:

$MailChimp = new Mailchimp('YOUR_MAILCHIMP_API_KEY');
$lists = $MailChimp->helper->listsForEmail(array("email" => $email));

您需要进行适当的错误检查;例如,如果电子邮件地址未订阅任何列表,它将抛出Mailchimp_List_NotSubscribed