Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MailChimp API member-info issue

Tags:

php

mailchimp

I need to retrieve all users infos via api, looking for it in the documentation I found this: http://apidocs.mailchimp.com/api/2.0/lists/member-info.php

This is my code:

$params = array(
            'id' => $list_id,
            'emails' => array(
                            'euid' => $member_id,
                        ),
        );
        $infos = $this->MailChimp->call('lists/member-info', $params);

print_r($infos);

and this is the result:

Array ( [success_count] => 0 [error_count] => 1 [errors] => Array ( [0] => Array ( [email] => 63a885b7cf [error] => "email" should be a struct [code] => -100 ) ) [data] => Array ( ) )  

What does " "email" should be a struct " means?

like image 382
Christian Giupponi Avatar asked Sep 23 '13 10:09

Christian Giupponi


People also ask

Do API keys provide full access to your Mailchimp account?

API keys grant full access to your Mailchimp account and should be protected the same way you would protect your password.

How do I add first name to member data in Mailchimp?

Click on an existing text block or add a new text block to your campaign and click to edit the text block. Click (place your cursor) wherever you'd like the first name to appear to the right side of the screen, click “Merge Tags” in the toolbar and then click “First Name”.

Why are my Mailchimp links not working?

Make sure your link is really a link. To ensure your formatting is correct before you send, enter preview mode and use the link checker tool. If you're working with the new email builder, we'll mark broken links with an exclamation point icon as you add your content.


3 Answers

This also works and is slightly simpler:

$result = $MailChimp->call('lists/member-info', array(
            'id'        => $list_id,
            'emails'    => array(array('email'=>$email))
          ));

The above example uses this API: https://github.com/drewm/mailchimp-api/

like image 91
Justin Tilson Avatar answered Oct 22 '22 16:10

Justin Tilson


Solved! My $params array was wrong.

MailChimp need an array format in this way:

$params = array(
            'id' => $list_id,
            'emails' => array(
                          0 => array(
                              'euid' => $member_id,
                          ),
                        ),
        );
like image 27
Christian Giupponi Avatar answered Oct 22 '22 16:10

Christian Giupponi


Mine does this as follows:

array(
  '0' => array('email' => $mail1)
  '1' => array('email' => $mail2)
  ...
  ...
);

Thanks,

like image 31
Pratip Ghosh Avatar answered Oct 22 '22 16:10

Pratip Ghosh