Reputation: 3045
How to get the Mailchimp member information with each list subscribtion status?
$mailChimp = new MCAPI($this->api_key);
$listid = 'xxxxxxxxxx';
$retval = $mailChimp->listMemberInfo( $listid, '[email protected]' );
if ($this->_mailChimp->errorCode) {
$error['Code'] = $this->_mailChimp->errorCode;
$error['Message'] = $this->_mailChimp->errorMessage;
return $error;
}
print_r($retval);
Return array:
Array
(
[id] => xxxxxxxxxx
[email] => [email protected]
[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] => [email protected]
[MERGE0] => [email protected]
[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
)
)
But here I don't know how to check that which List I have subscribed and Which is Unsubscribed. Because
[lists] => Array
(
[xxxxxxxxxx] => subscribed
[xxxxxxxxxx] => subscribed
[xxxxxxxxxx] => subscribed
)
Here all the lists are not match with my Original Lists Id getting list using
lists()
method of Mailchimp
$retval = $mailChimp->lists();
Can anyone has idea how to check that my email id: '[email protected]'
has subscribed to this lists and unsubscribed to this list.
I want to know the status of each list by given List_ID and Email_ID
I have used PHP as technology.
Upvotes: 3
Views: 2231
Reputation: 7611
I realise this is an old question, but for future visitors:
For version 2 of the API (the Mailchimp
class has public $root = 'https://api.mailchimp.com/2.0';
), this works for me:
$MailChimp = new Mailchimp('YOUR_MAILCHIMP_API_KEY');
$lists = $MailChimp->helper->listsForEmail(array("email" => $email));
You'll need appropriate error checking; for example, it'll throw a Mailchimp_List_NotSubscribed
if the email address isn't subscribed to any lists.
Upvotes: 1