通过MailChimp 2.0 API向用户订阅组 [英] Subscribing users with groups through MailChimp 2.0 API

查看:93
本文介绍了通过MailChimp 2.0 API向用户订阅组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在这个问题上工作了好几个小时,而且似乎找不到解决方法,希望有人可以提供帮助!

I've been working on this problem for hours and can't seem to find the solution, hopefully someone can help!

我正在尝试在HTTPS网站上创建一个简单的MailChimp订阅表单,因此必须使用API​​.我使用他们建议的超级简单mailchimp-api" PHP包装器,并尝试根据表单中选中的复选框将订阅者添加到兴趣组.所有相关的复选框都被命名为"group []",以便PHP将其作为数组发布.

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
            ));

我进行测试时,正确创建了用户,但未选择任何兴趣组.我已经仔细检查了组ID和组名是否正确.我什至尝试对GROUPS数组进行硬编码都无济于事.

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.

传递给API的merge_vars $ args的示例为:

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
                            )

                    )

            )

    )

据我了解,这是完全正确的,所以我只是不了解问题所在.有人可以看到我在做什么吗?还是API损坏了?

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?

谢谢

乔什

推荐答案

我来到这个未回答"的问题,答案为零,但发现问题的注释中实际上已经回答了该问题.我正在复制评论以反映问题已经收到答案.

I arrived at this "unanswered" question with zero answers, but found it was actually already answered in the comments of the question. I'm copying the comments to reflect the question has already received an answer.

OMG,5小时后我才发现问题所在!对于其他陷入困境的人 由此-键(非值)分组","id"和组"全部 需要小写.我真的不明白为什么 其他字段在任何地方都被记录为大写,实际上 大写时工作.我认为这是他们喜欢的残酷笑话 在开发人员上玩. –乔什(Josh)13年11月28日在12:37

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


在较旧的API版本中,它们是大写的.他们改变了它 2.0. – Daniel Rikowski 14年3月16日在21:49

In the older API versions they were in upper case. They changed it in 2.0. – Daniel Rikowski Mar 16 '14 at 21:49

这篇关于通过MailChimp 2.0 API向用户订阅组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆