微信公众号的模板消息封装类
转载请注明出处,作者创作不易
class sendMsg
{
protected $appid;
protected $secrect;
protected $accessToken;
function __construct($appid, $secrect)
{
$this->appid = $appid;
$this->secrect = $secrect;
$this->accessToken = $this->getToken($appid, $secrect);
}
private function httpPost($url='', $param='')
{
if (empty($url) || empty($param)) {
return false;
}
$postUrl = $url;
$curlPost = $param;
$ch = curl_init($postUrl);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);