我试图在HTTPS站点上创建一个简单的MailChimp订阅表单,因此必须使用该API.我使用他们建议的“超简单mailchimp-api”PHP包装器,并且正在尝试根据表单中选中的复选框将我的用户添加到兴趣组.所有相关的复选框都被命名为“group []”,以便PHP将它们作为数组发布.
我正在通过下面的包装:
$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 ));
当我测试时,正确创建用户,但没有选择兴趣组.我已仔细检查分组ID和组名称是否正确.我甚至尝试硬编码一个数组为GROUPS无效.
传递给API的merge_vars $args的示例有:
[merge_vars] => Array ( [FNAME] => Test [LNAME] => Test [COMPANY] => [STATE] => TAS [GROUPINGS] => Array ( [0] => Array ( [ID] => 14093 [GROUPS] => Array ( [0] => Invest [1] => Deposit Bonds ) ) ) )
从我能理解的这是完全正确的,所以我只是不明白问题所在.谁能看到我在做错什么?还是API破了?
谢谢
玩笑
OMG,after 5h I just discovered the problem! For anyone else stumped
by this – the keys (not values) “groupings”,“id” and “groups” all
need to be lower case. I really don’t understand why when all the
other fields are documented everywhere as being uppercase and indeed
work when they are uppercase. I assume it’s some cruel joke they enjoy
playing on developers. – Josh Nov 28 ’13 at 12:37
In the older API versions they were in upper case. They changed it in 2.0. – Daniel Rikowski Mar 16 ’14 at 21:49