I've been working on this problem for hours and can't seem to find the solution, hopefully someone can help!
I'm trying to create a simple MailChimp subscribe form on an HTTPS site and hence must use the API. I am using the "super simple mailchimp-api" PHP wrapper they suggest, and am trying to add my subscribers to interest groups based on checkboxes selected in the form. All the relevant checkboxes are named "group[]" so that PHP will POST them as an array.
I am passing the below to the wrapper:
$MailChimp = new MailChimp('api_key_removed');
$result = $MailChimp->call('lists/subscribe', array(
'id' => 'list_ID_removed',
'email' => array( 'email' => $_POST['email'] ),
'merge_vars' => array( 'FNAME' => $_POST['fname'], 'LNAME' => $_POST['lname'], 'COMPANY' => $_POST['company'], 'STATE' => $_POST['state'],
'GROUPINGS' => array(
array(
'ID' => 14093,
'GROUPS' => $_POST['group']
)
)
),
'double_optin' => false,
'update_existing' => true,
'replace_interests' => false,
'send_welcome' => true
));
When I test, the users are created correctly but no interest groups are selected. I have double checked that both the grouping ID and group names are correct. I have even tried hardcoding an array for GROUPS to no avail.
An example of the merge_vars $args passed to the API are:
[merge_vars] => Array
(
[FNAME] => Test
[LNAME] => Test
[COMPANY] =>
[STATE] => TAS
[GROUPINGS] => Array
(
[0] => Array
(
[ID] => 14093
[GROUPS] => Array
(
[0] => Invest
[1] => Deposit Bonds
)
)
)
)
From what I can understand this is exactly right, so I'm just not understanding where the problem lies. Can anyone see what I'm doing wrong? Or is the API broken?
Thanks
Josh