php – 通过MailChimp 2.0 API订阅用户组

前端之家收集整理的这篇文章主要介绍了php – 通过MailChimp 2.0 API订阅用户组前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我一直在处理这个问题几个小时,似乎找不到解决方案,希望有人可以帮助!

我试图在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

原文链接:https://www.f2er.com/php/139460.html

猜你在找的PHP相关文章