我目前正在使用 MailChimp API for PHP,版本 1.3.1 ( http://apidocs.mailchimp.com/api/downloads/#php )
我在 MailChimp 中设置了一个列表,并希望动态添加:
- 列表的订阅者(完成:
$objMailChimp->listBatchSubscribe($strMailingListID, ...)
) - 兴趣分组(完成:
$objMailChimp->listInterestGroupingAdd($strMailingListID, ...)
) - 兴趣组到这些分组(完成:
$objMailChimp->listInterestGroupAdd($strMailingListID, ...)
) - 分配给相关组的订户(未完成)
API ( http://apidocs.mailchimp.com/api/1.3/#listrelated) 在如何将订阅者添加到兴趣组方面有些不清楚 - 这里有人有任何想法吗?
最佳答案
从 MailChimp 的 API 2.0 版开始,这应该可以工作:
$merge_vars = array(
'GROUPINGS' => array(
array(
'name' => "GROUP CATEGORY #1", // You can use either 'name' or 'id' to identify the group
'groups' => array("GROUP NAME","GROUP NAME")
),
array(
'name' => "GROUP CATEGORY #2",
'groups' => array("GROUP NAME")
)
)
);
来源:http://apidocs.mailchimp.com/api/2.0/lists/subscribe.php
使用准系统 PHP 包装器 (https://github.com/drewm/mailchimp-api/),然后您可以通过 lists/subscribe 或 lists/batch-subscribe 将其发送到 MailChimp:
$MailChimp = new MailChimp('API_KEY');
$result = $MailChimp->call('lists/subscribe', array(
'id' => 'LIST ID',
'email' => array('email'=>'trevor@example.com'),
'merge_vars' => $merge_vars
));
关于php - MailChimp API PHP - 添加到兴趣组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8761595/