[英]Mailchimp API CURL - Auto-subscribe user with Groupings
I am trying to auto-subscribe a user when they click on "Subscribe to Newsletter" on my website's signup form. 当用户单击我网站的注册表单上的“订阅新闻通讯”时,我试图自动为其进行订阅。
I have the CURL built up and it works, but I need to configure it to add the user's registration type into Mailchimp. 我已经建立了CURL并且它可以工作,但是我需要对其进行配置以将用户的注册类型添加到Mailchimp中。
When the user signs up, we ask them if they drive a "taxi", "car", "bus", "truck" or "motorcycle". 当用户注册时,我们询问他们是否驾驶“出租车”,“汽车”,“公共汽车”,“卡车”或“摩托车”。 In Mailchimp I have a group called "Transit" with the above options.
在Mailchimp中,我有一个带有上述选项的名为“运输”的组。
This is the current CURL command I am using: 这是我正在使用的当前CURL命令:
$apikey = "MY API KEY";
$merge_vars = Array(
'FNAME' => $fname,
'LNAME' => $lname,
'GROUPINGS'=>array(
array('name'=>'Transit:', 'groups'=>'car')
)
);
$listID = 'MY LIST ID';
$email = $email;
$url = sprintf('http://us11.api.mailchimp.com/1.2/?method=listSubscribe&apikey=%s&id=%s&email_address=%s&merge_vars[OPTINIP]=%s&merge_vars[MERGE1]=%s&merge_vars[MERGE2]=%s&output=json', $apikey, $listID, $email, $merge_vars, $merge_vars['FNAME'], $merge_vars['LNAME'], $_SERVER['REMOTE_ADDR']);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
When the user signs up, it doesn't store that they drive a car in the transit groupings. 当用户注册时,它不会在运输分组中存储他们驾驶汽车的信息。
Step 1 should really be using a version of the API that isn't 8 years old and deprecated! 第1步实际上应该使用未使用8年且已弃用的API版本!
In the latest version , this is simply done by using an interests
parameter on the list member add call . 在最新版本中 ,只需在列表成员add调用上使用
interests
参数即可完成此操作。 You'll grab the interest IDs for each of your options ('car', 'truck', etc..) and then your member object looks like this: 您将获取每个选项(“汽车”,“卡车”等)的兴趣ID,然后您的成员对象如下所示:
{
"email_address": "some_address@mail.com",
"status": "subscribed",
"interests": {
"abc123": true,
"def456": false
}
}
Where abc123
and def456
are the IDs of the interests you're using. 其中
abc123
和def456
是您正在使用的兴趣的ID。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.