使用 MailChimp API V3.0 创建事件。
我想创建一个发送给具有特定兴趣的用户的事件。看起来这在文档中是可能的,但我已经尝试了我能想到的每一种排列。只要省略 segment_ops 成员,我就可以很好地创建事件。有没有人有可以执行此操作的 PHP 代码示例?
兴趣的处理似乎很奇怪,因为您在通过 API 设置用户兴趣时没有包括兴趣类别。我不确定这对事件创建有何影响。
最佳答案
我已经让它工作了,可以在这里找到 API 定义 https://us1.api.mailchimp.com/schema/3.0/Segments/Merge/InterestSegment.json
兴趣必须在兴趣类别下分组(在 UI 的某些部分称为“组”)。
这是收件人数组的 segment_opts 成员的 JSON:
"segment_opts": {
"match": "any",
"conditions": [{
"condition_type": "Interests",
"field": "interests-31f7aec0ec",
"op": "interestcontains",
"value": ["a9014571b8", "5e824ac953"]
}]
}
这是带有注释的 PHP 数组版本。 “匹配”成员指的是“条件”数组中的规则。该段可以匹配任何条件、所有条件或不匹配任何条件。此示例只有一个条件,但其他条件可以作为附加数组添加到“条件”数组中:
$segment_opts = array(
'match' => 'any', // or 'all' or 'none'
'conditions' => array (
array(
'condition_type' => 'Interests', // note capital I
'field' => 'interests-31f7aec0ec', // ID of interest category
// This ID is tricky: it is
// the string "interests-" +
// the ID of interest category
// that you get from MailChimp
// API (31f7aec0ec)
'op' => 'interestcontains', // or interestcontainsall, interestcontainsnone
'value' => array (
'a9014571b8', // ID of interest in that category
'5e824ac953' // ID of another interest in that category
)
)
)
);
关于php - 使用 MailChimp API V3.0 创建具有动态分割的事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35785278/