我如何添加订阅到不同的片段


How can I add that subscribe to different segments?

我想通过注册源添加我的订阅者不同的段。我在Mailchimp中创建了两个片段。我如何添加订阅到不同的片段?I使用API v2.

<?php
  include('MailChimp.class.php');
  $MailChimp = new 'Drewm'MailChimp('ebae376c690e50d98ce069482eec5244-us8');
  $result = $MailChimp->call('lists/subscribe', array(
    'id'                => 'fde03148a4',
    'email'             => array( 'email' => $_POST['email'] ),
    'merge_vars'        => array(
    'MERGE2' => $_POST['name'] // MERGE name from list settings
    // there MERGE fields must be set if required in list settings
  ),
  'double_optin'      => true,
  'update_existing'   => false,
  'replace_interests' => false
));
if( $result === false ) {
    // response wasn't even json
}
else if( isset($result->status) && $result->status == 'error' ) {
    echo $result->status, $result->code, $result->name, $result->error;
}
?>

来自API文档:您需要将groupings项添加到merge_vars数组中。这应该是一个包含idgroups的关联数组的数组,其中包含您想要添加用户的组的名称。

在v3中,这要简单得多。有一个interests对象,它只接受id和布尔值来确定用户是否被添加到组或从组中删除。