MailChimp API PHP - 添加到兴趣组
我目前正在使用 PHP 的 MailChimp API,版本 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)对于如何将订阅者添加到兴趣组有些不清楚 - 这里有人有任何想法吗?
I'm currently using the MailChimp API for PHP, version 1.3.1 (http://apidocs.mailchimp.com/api/downloads/#php)
I've set up a list in MailChimp, and would like to dynamically add:
- Subscribers to the list (done:
$objMailChimp->listBatchSubscribe($strMailingListID, ...)
) - Interest Groupings (done:
$objMailChimp->listInterestGroupingAdd($strMailingListID, ...)
) - Interest Groups into those Groupings (done:
$objMailChimp->listInterestGroupAdd($strMailingListID, ...)
) - Subscribers assigned to relevant Groups (not done)
The API (http://apidocs.mailchimp.com/api/1.3/#listrelated) is somewhat unclear on how to add a subscriber to an interest group - does anyone here have any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
从 MailChimp 的 API 2.0 版开始,这应该可以工作:
来源:http://apidocs.mailchimp.com/ api/2.0/lists/subscribe.php
使用准系统 PHP 包装器 (https://github.com/drewm/mailchimp-api/)然后您可以通过列表/将其发送到 MailChimp订阅或列表/批量订阅:
As of version 2.0 of MailChimp's API, this should work:
Source: http://apidocs.mailchimp.com/api/2.0/lists/subscribe.php
Using a barebones PHP wrapper (https://github.com/drewm/mailchimp-api/) you can then send this to MailChimp via either the lists/subscribe or lists/batch-subscribe:
对于 MailChimp API v3
您必须找到您想要添加的群组(兴趣)的 ID。不幸的是,这在 MailChimp 仪表板上的任何地方都找不到。
查找“兴趣”ID(而不是创建脚本)的最简单方法是转到 MailChimp Playground,然后输入您的 API 密钥后,路由到...
OR
因此,当涉及到实际进行 POST 调用(“member”创建)时,您可能需要类似于...
PUT 调用(“member”编辑) 例子...
For MailChimp API v3
You have to find out the ID of the group (interest) that you are wanting to add to. Unfortunately this cannot be found anywhere on the MailChimp dashboard.
The easiest way to find out the 'interest' ID (rather than creating a script) is to go to the MailChimp playground and then, after entering in your API key, route to...
OR
So when it comes to actually making the POST call ('member' create), you would want something on the lines of...
A PUT call ('member' edit) example...
我无法让此页面上的其他答案发挥作用。这是我必须使用的合并变量:
I could not get the other answers on this page to work. Here's the merge vars that I had to use:
使用
GROUPINGS
合并变量:Use
GROUPINGS
merge var:这是我要工作的代码
Here's the code I got to work
这是 Justins 答案的一种变体,但在尝试了上述所有内容后,这是我可以使用 DrewM 的 MailChimp 包装器的唯一答案。
如果您不确定您的组列表 ID 并希望使用它,您可以致电:
This is a variation of Justins answer but having tried all the above this is the only one I could get to work with DrewM's MailChimp wrapper
If you are unsure of your groups lists ID and wish to use it you can call:
另请注意 listUpdateMember 的可选但非常重要的最后一个参数,默认情况下 replace_interests 设置为 true,因此它将覆盖您正在更新的用户过去可能拥有的任何订阅。如果您想添加新组而不触及以前的组,只需传递您想要添加的新组名称并将 replace_interests 设置为 false。
Also please note optional but very important last parameter of listUpdateMember, by default replace_interests it set to true so it will overwrite any subscription the user you are updating could have had in the past. If you want to add new ones not touching previous ones just pass the new group name you wanna add and set replace_interests to false.
使用 DrewM 的 MailChimp 包装器 和数组简写语法的示例 (PHP 5.4+) 添加到组:
您需要对“名称”进行分组OR 'id',两者都不需要。要获取分组 ID,请使用: lists/interest-groupings
Example using DrewM's MailChimp wrapper and shorthand syntax for arrays (PHP 5.4+) add to groups:
You need grouping 'name' OR 'id', both are not needed. To get grouping ID use: lists/interest-groupings