cumtoser.io,是一个国外的网站,存储邮箱,然后固定时间或事件去发送要给用户的邮件
//添加cumtoser用户 如果cumtoser_id存在则会更新用户信息如果不存在则会新建一条用户信息
$ch = curl_init();
$id='';//cumtoser_id 必填项
$name="apikey";
$password="api secret";
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, 'https://track.customer.io/api/v1/customers/'.$id);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Authorization: Basic ".base64_encode("$name:$password")
]);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
if($data) {
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
}
curl_setopt ($ch, CURLOPT_CUSTOMREQUEST, "PUT");
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
添加事件标签传输到cumtoser.io
//添加event 标签
function add_events_people($customer_name,$data) {
//$customer_name cumtoser_id
//$data event标签名称
$ch = curl_init();
$name="apikey";
$password="api secret";
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, 'https://track.customer.io/api/v1/customers/'.$customer_name.'/events');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Authorization: Basic ".base64_encode("$name:$password")
]);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
// return json_encode($data);
if($data) {
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
}
curl_setopt($ch, CURLOPT_CUSTOMREQUEST,'POST');
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
原创©本文章为教腾豪原创,未经许可,禁止转载
0条评论