1 appid = $appid;
9 $this->appSecret = $appSecret;
10 }
11 12 function returnKefu($openid,$content){
13 $access_token = $this->getAccessToken();
14 $url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=$access_token";
15 $responseText = array("touser"=>$openid,"msgtype"=>"text","text"=>array("content"=>$content));
16 $responjson = json_encode($responseText);
17 $res = $this->httpPost($url,$responjson);
18 echo $res;
19 }
20 function returnPic($openid,$content){
21 $access_token = $this->getAccessToken();
22 $url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=$access_token";
23 $responseText = array("touser"=>$openid,"msgtype"=>"image","image"=>array("media_id"=>"Xfh-2sT-4HHz0z1GrAgb1tlJowuAJuyI-O6AzFX_TT3UsZHwqdsjyUCY6GJGviMi"));
24 $responjson = json_encode($responseText);
25 $res = $this->httpPost($url,$responjson);
26 echo $res;
27 }
28 29 30 31 function getAccessToken(){
32 $file_ticket = "access_token.json";
33 if(!file_exists($file_ticket)){
34 $file = fopen($file_ticket,'w');
35 }
36 $data = json_decode(file_get_contents($file_ticket));
37 if($data){
38 //如果文件存在且内容过期 39 if($data->expires_in
로그인 후 복사