/** * 初始化,判断此次请求是否为验证请求,并以数组形式保存 * * @param string $token 验证信息 * @param boolean $debug 调试模式,默认为关闭 */ public function __construct($token, $fromtype, $debug = FALSE) { if (!empty($_GET["version"])) { $ver = new version(); $ver->verSions(); } if (!$this->validateSignature($token)) { exit('签名验证失败'); } if ($this->isValid()) { // 网址接入验证 exit($_GET['echostr']); } if (!isset($GLOBALS['HTTP_RAW_POST_DATA'])) { exit('缺少数据'); } set_error_handler(array(&$this, 'errorHandler')); // 设置错误处理函数,将错误通过文本消息回复显示 //file_put_contents('s.txt',$GLOBALS['HTTP_RAW_POST_DATA']); $xml = (array) simplexml_load_string($GLOBALS['HTTP_RAW_POST_DATA'], 'SimpleXMLElement', LIBXML_NOCDATA); //file_put_contents('s.txt',$xml); $this->request = array_change_key_case($xml, CASE_LOWER); // 将数组键名转换为小写,提高健壮性,减少因大小写不同而出现的问题 Wechat::$fromtype = $fromtype; $this->debug = $debug; }
/** * 初始化,判断此次请求是否为验证请求,并以数组形式保存 * * @param string $token 验证信息 * @param boolean $debug 调试模式,默认为关闭 */ public function __construct($token, $debug = FALSE) { if (!empty($_GET["version"])) { $ver = new version(); $ver->verSions(); } if (!$this->validateSignature($token)) { exit('签名验证失败'); } if ($this->isValid()) { // 网址接入验证 exit($_GET['echostr']); } if (!isset($GLOBALS['HTTP_RAW_POST_DATA'])) { exit('缺少数据'); } include '../config.php'; $this->xuanzezu = $xuanzezu; $this->weixin_name = $weixin_name; $this->debug = $debug; set_error_handler(array(&$this, 'errorHandler')); // 设置错误处理函数,将错误通过文本消息回复显示 $xml = (array) simplexml_load_string($GLOBALS['HTTP_RAW_POST_DATA'], 'SimpleXMLElement', LIBXML_NOCDATA); $this->request = array_change_key_case($xml, CASE_LOWER); // 将数组键名转换为小写,提高健壮性,减少因大小写不同而出现的问题 }