<?php require_once 'weixinlib/textmsg.php'; require_once 'weixinlib/secretmsg.php'; require_once 'weixinlib/clickmsg.php'; define('TOKEN', 'icoding520'); $wechatObj = new wechatCallbackapiTest(); $wechatObj->response(); class wechatCallbackapiTest { public function response() { $echoStr = $_GET['echostr']; //valid signature , option if ($this->checkSignature()) { echo $echoStr; $this->responseMsg(); exit; } } public function responseMsg() { //get post data, May be due to the different environments $postStr = $GLOBALS['HTTP_RAW_POST_DATA']; //extract post data if (!empty($postStr)) { $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA); $fromUsername = $postObj->FromUserName; $toUsername = $postObj->ToUserName; $getMsgType = $postObj->MsgType; $PicUrl = '';
header('content-type:text/html;charset=utf-8'); ini_set("display_errors", "Off"); define("TOKEN", $_GET['token']); date_default_timezone_set("PRC"); $wechatObj = new wechatCallbackapiTest(); $check_attached = $wechatObj->chaxun(0, $_GET['token'], 'get_member_detail'); $checked_info = mysql_fetch_array($check_attached); if ($checked_info['attached'] == 0) { $wechatObj->chaxun(0, TOKEN, 'updateattach'); } if (isset($_GET['echostr'])) { $wechatObj->valid(); } define('uf', $_GET['token']); define("serverip", $_SERVER['HTTP_HOST']); $wechatObj->response(TOKEN); class wechatCallbackapiTest { private $timestamp; public $temp; public $row = 0; public $fromUsername; public $toUsername; public $firstView = true; public $firstViewWord = true; public $viewId; public $viewing = 0; public $piao = 0; public $now; public $MsgType; public $T = 60;