标签:
发送文本消息:
$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