15年软件开发经验,只做源码定制!

原创设计 定制开发

满足您的个性化需求

当前位置:首页 后端开发 Thinkphp5

php_curl 调取cumtoser.io API,国外一个统计邮箱,然后发送邮件的一个平台

教腾豪| 发布于 2021-09-24 18:27:54| 51阅读| 0点赞| 0评论
举报

php_curl,cumtoser.io API,请求连接API

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: <a href="https://www.qinfenniao.com/nav/%E7%BD%91%E7%AB%99%E5%BC%80%E5%8F%91.html" target="_blank">app</a>lication/<a href="https://www.qinfenniao.com/article.html?name=js" target="_blank">js</a>on",
        "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, <a href="https://www.qinfenniao.com/article.html?name=js" target="_blank">js</a>on_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: <a href="https://www.qinfenniao.com/nav/%E7%BD%91%E7%AB%99%E5%BC%80%E5%8F%91.html" target="_blank">app</a>lication/<a href="https://www.qinfenniao.com/article.html?name=js" target="_blank">js</a>on",
        "Authorization: Basic ".base64_encode("$name:$password")
    ]);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    // return <a href="https://www.qinfenniao.com/article.html?name=js" target="_blank">js</a>on_encode($data);
    if($data) {
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, <a href="https://www.qinfenniao.com/article.html?name=js" target="_blank">js</a>on_encode($data));
    }
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST,'POST');
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}
0

0条评论

别默默看啦~登录/注册一起参与讨论吧~

热门标签

教腾豪
微信扫一扫立即咨询
账号登录|扫码登录

立即注册 |忘记密码?

欢迎注册

已有账号马上登录

重置密码

扫码绑定微信
微信扫一扫

绑定手机号

分享到-微信

举报

  • 举报类型:

  • 举报描述:

您好,当前积分不足。

在线客服
拨打电话
17330196230 13230981129
顶部