php - 使用 MailChimp API V3.0 创建具有动态分割的事件

标签 php mailchimp segment mailchimp-api-v3.0

使用 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/

相关文章:

php - 如何使用 preg_replace 用数组中的字符串替换子字符串? (PHP)

php - 如何更改 WordPress 中的图片作者?

javascript - jQuery - 如何在嵌入 Mailchimp 表单电子邮件提交后添加 "Thank you"消息?

MailChimp 多次发送同一封电子邮件

email - Mandrill 和浏览器中的 View 功能

text - VHDL - 包中的类型声明

php - 文件上传验证

php - 在哪里可以找到用 PHP 编写的好的 VCS?

python - 如何使用 gstreamer 从较长的源片段制作音频剪辑?

node.js - ffmpeg 段不实时显示文件大小更新