通过 MailChimp API v2.0 将用户添加到兴趣组 [英] Add users to interest group via MailChimp API v2.0

查看:22
本文介绍了通过 MailChimp API v2.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"
    }
  }
}

$email 是一个结构体,这里是 $var_dump($email):

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.

我看过这个问题帮助我到目前为止,但它使用的 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.

我现在的代码:

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

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

完美运行.

这篇关于通过 MailChimp API v2.0 将用户添加到兴趣组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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