Reputation: 231
I'm using this MailChimp api v3 wrapper https://github.com/drewm/mailchimp-api/tree/api-v3
Using the example I can add an email to my list but cannot add it to one of my interest groups.
This is the example code:
$MailChimp = new MailChimp('abc123abc123abc123abc123abc123-us1');
$result = $MailChimp->post('lists/b1234346/members', array(
'email_address' => 'davy@example.com',
'status' => 'subscribed',
'merge_fields' => array('FNAME'=>'Davy', 'LNAME'=>'Jones'),
'interests' => array( '2s3a384h' => true )
));
print_r($result);
My understanding is the key in that array entry for interests is the ID of the group. I created a group in MailChimp, which has a group title and group names. I can see an id when I hover over the group title edit button, and also the group name edit button. If I hover over the "0 subscribers" for a group name I can see that same id and a group_id. I've tried both values and I get this error:
Array ( [type] => http://kb.mailchimp.com/api/error-docs/400-invalid-resource [title] => Invalid Resource [status] => 400 [detail] => Invalid interest ID: '39561'. [instance] => 12c1ab46-a0b5-4014-8107-08cfa97a9a94 )
I've googled and still can't find the answer. Any help?
Upvotes: 22
Views: 16842
Reputation: 148
A quick and dirty way to capture all of the Interest IDs...
$MailChimp = new MailChimp('abc123abc123abc123abc123abc123-us1');
$result = $MailChimp->post('lists/b1234346/members', array(
'email_address' => 'davy@example.com',
'status' => 'subscribed',
'merge_fields' => array('FNAME'=>'Davy', 'LNAME'=>'Jones')
));
print_r($result);
Your print_r
after not specifying the "interests" key in the post should provide you with an interests array with the IDs telling you they are all marked as false.
["interests"]=> array(7) { ["258ad948a1"]=> bool(false) ["8e30162ec8"]=> bool(false) ["f2f79df229"]=> bool(false) ["b4e2f6effc"]=> bool(false) ["4fb0927fef"]=> bool(false) ["f2d1e06470"]=> bool(false) ["9f6c7c4db2"]=> bool(false) }
Upvotes: 1
Reputation: 30114
You can get the Id of the specific interest option
not the group id, by going to the playground
Then you navigate to your list and group:
When you click on the name of the interest option it will show the option meta data, including it's id:
Upvotes: 30
Reputation: 1172
Interests are (can be? must be?) grouped under interest-categories, but you only need the ID of the interest itself, not the ID of the interest-category when setting it for the user.
Your error may be from using the interest-category ID instead of the specific interest ID.
Upvotes: 19