/
interface.php
38 lines (34 loc) · 1.29 KB
/
interface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
/**
* wechat interface code
*/
ini_set('display_errors', '1');
//include other file
require_once dirname(__FILE__) . '/class/WechatValid.php';
require_once dirname(__FILE__) . '/class/WechatCallBackEchoServer.php';
require_once dirname(__FILE__) . '/common/GlobalFunctions.php';
$wechatValid = new WechatValid();
$wechatValid->valid();
$wechatObj = new WechatCallBackEchoServer();
$postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
interface_log(INFO, EC_OK, "******************************************************");
interface_log(INFO, EC_OK, "*************** interface requrest start *************");
interface_log(INFO, EC_OK, 'request:' . $postStr);
interface_log(INFO, EC_OK, 'get:' . var_export($_GET, true));
if (empty($postStr)) {
interface_log(ERROR, EC_OK, "post data error!");
exit (0);
}
$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
$ret = $wechatObj->init($postObj);
if (!$ret) {
interface_log(ERROR, EC_OK, "init post object error!");
exit (0);
}
$retStr = $wechatObj->process();
interface_log(INFO, EC_OK, "response:" . $retStr);
echo $retStr;
interface_log(INFO, EC_OK, "*************** interface request end ****************");
interface_log(INFO, EC_OK, "******************************************************");
interface_log(INFO, EC_OK, "");
?>