|
123456789101112131415161718192021222324252627282930313233 |
- <?php
- //调用
- require_once './Common/Config.php';
- require_once './Common/WeChat.class.php';
- write_log("index接口有调用");
- $wechat=new WeChat(APPID,APPSECRET);
- $array=$wechat->responseMsg();
- if (!$array){
- exit;
- }
- $msgtype=$array['MsgType'];
- switch ($msgtype){
- case "event":
- write_log("index--event--有接口调用");
- $result=$wechat->eventMsg($array);
- //$wechat->insertOpenid($array,$array['Event']);
- break;
- case "text":
- write_log("index--text--有接口调用");
- $result=$wechat->textMsg($array);
- //echo $result;
- break;
- }
- echo $result;
- function write_log($activation){
- $dir="./Log";
- if (!is_dir($dir)){
- mkdir($dir);
- }
- $open=fopen($dir."/log.txt","a");
- fwrite($open,date("Y-m-d H:i:s")."\t".$activation."\r\n");
- fclose($open);
- }
|