通过MailChimp API 2.0版将用户添加到利益集团 [英] Add users to interest group via MailChimp API v2.0

查看:142
本文介绍了通过MailChimp API 2.0版将用户添加到利益集团的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要通过MailChimp API将用户添加到一个利益集团。

I want to add a subscriber to an interest group via the MailChimp API.

这是我的 $ merge_vars 数组:

$merge_vars = array(
    'GROUPINGS' => array(
        0 => array(
            'id' => 17385, // The group list ID
            'groups' => "Test 123", // A test group, that does exist
        )
    )
);              

这就是我如何更新会员:

and this is how I'm updating the member:

$update = $mc->lists->updateMember(self::$mainListID, $email, $merge_vars);

下面是一个的var_dump($ merge_vars)

array(1) {
  ["GROUPINGS"]=>
  array(1) {
    [0]=>
    array(2) {
      ["id"]=>
      int(17385)
      ["groups"]=>
      string(8) "Test 123"
    }
  }
}

$电子邮件是一个结构,这里的 $的var_dump($电子邮件)

and $email is a struct, here's $var_dump($email):

array(1) {
  ["email"]=>
  string(11) "my@mail.com"
}

我要失魂落魄,因为API没有返回一个错误,似乎一切顺利,除了不被添加到列表中的用户的大问题。

I'm about to be driven to distraction, because the API doesn't return an error, everything seems to go smoothly, except for the big problem of the user not being added to the list.

我看了<一个href=\"http://stackoverflow.com/questions/8761595/mailchimp-api-php-add-to-interest-group/8809708#8809708\"标题=这个问题>这个问题这让我得到这么远,但它使用的API的版本是1.3,而且可能有一些用它做。

I've looked at this question which helped me get so far, but the version of the API it uses is 1.3 and that might have something to do with it.

我在做什么错了?

推荐答案

好吧,我想通了。

虽然我可以的宣誓的我已经尝试过这种方式......这些团体是一个数组,即使单个组。

Although I could have sworn I'd already tried it this way... the groups have to be an array, even for a single group.

我现在的code:

$merge_vars = array(
    'GROUPINGS'=> array(
        array(
            'id' => 17385,
            'groups' => array($post['listName'])
        )
    )
);

$mc->lists->updateMember(self::$mainListID, $email, $merge_vars);

完美的作品。

这篇关于通过MailChimp API 2.0版将用户添加到利益集团的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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