码迷,mamicode.com
首页 > 微信 > 详细

微信开发:客服接口向用户发送消息

时间:2015-08-01 11:18:45      阅读:462      评论:0      收藏:0      [点我收藏+]

标签:

 

发送文本消息:

$access_token = "";

$url=‘https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=‘.$access_token;
$content = ‘{
    "touser":"‘.$openid.‘",
    "msgtype":"text",
    "text":
    {
         "content":"‘.$content.‘"
    }
}‘;  
$htt = $this->https_post($url,$content);

var_dump($htt);

 

public function https_post($url,$data){
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $result = curl_exec($curl);
        if(curl_errno($curl)) {
            return ‘Errno‘.curl_errno($curl);
        }
        curl_close($curl);
        return $result;
    }

微信开发:客服接口向用户发送消息

标签:

原文地址:http://www.cnblogs.com/wangyuman26/p/4693741.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!