首先打开thinkphp公共function.php文件
//获取服务器的access_token
function GetSeverToken(){
// $content=file_get_contents('https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.C('WX_appid').'&secret='.C('WX_appsecret').'');
$url= 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.C('WX_appid').'&secret='.C('WX_appsecret').'';
// echo $url;
$data=posthttps($url);
$content=explode('access_token":"',$data)[1];
// 获取access_token
$access_token=explode('","',$content)[0];
return $access_token;
}
//请求https
function posthttps($url){
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, 1);
c