Skip to content

Commit

Permalink
加入日志功能
Browse files Browse the repository at this point in the history
  • Loading branch information
lvfan2008 committed Jan 11, 2017
1 parent a9f478b commit 5fa07af
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions example/component_app_event.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
include_once "config.php";
include_once dirname(dirname(__FILE__)) . "/src/WxComponentService.class.php";

$url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
log_ex('wx_auth_msg', "component_app_event enter: url:{$url}");

$cfg = get_wx_config();
if (!$cfg) {
log_ex('wx_auth_msg', "get_wx_config failed!");
die("no access!");
}

Expand All @@ -18,6 +22,7 @@
$wxComponentService = new WxComponentService($wxComponentConfig, new FileCache($GLOBALS['cacheDir']));
$appId = $cfg['app_id'];

// debug模式,会记录一些日志,正式的时候,可以去掉。
$wxComponentService->getWxComponent()->debug = true;
$wxComponentService->getWxComponent()->logcallback = "log_wechat";

Expand All @@ -39,6 +44,7 @@
die('no access');
}

// debug模式,会记录一些日志,正式的时候,可以去掉。
$weObj->debug = true;
$weObj->logcallback = "log_wechat";

Expand All @@ -51,7 +57,7 @@
die($ret);
}
$weObj->getRev();
log_ex('wx_auth_msg', "appId:{$appId} receive data:" . $weObj->getRevContent());
log_ex('wx_auth_msg', "appId:{$appId} receive data:" . print_r($weObj->getRevData(),true));
$weObj->text("success")->reply('', true); // 简单测试回复success
log_ex('wx_auth_msg', "echo success");

Expand Down Expand Up @@ -127,8 +133,10 @@ function test_auto_case(&$wxComponentService, $appId)
die('no access');
}

// debug模式,会记录一些日志,正式的时候,可以去掉。
$weObj->debug = true;
$weObj->logcallback = "log_wechat";

$ret = $weObj->valid(true);
if ($ret === false) {
log_ex('wx_auth_msg', "appId:{$appId}, auth valid failed! param:" . print_r($_GET, true) . " weObj:" . print_r($weObj, true));
Expand All @@ -138,7 +146,7 @@ function test_auto_case(&$wxComponentService, $appId)
die($ret);
}
$weObj->getRev();
log_ex('wx_auth_msg', "appId:{$appId} receive data:" . $weObj->getRevContent());
log_ex('wx_auth_msg', "appId:{$appId} receive data:" . print_r($weObj->getRevData(),true));

if ($weObj->getRevType() == Wechat2::MSGTYPE_TEXT) {
$recv_txt = $weObj->getRevContent();
Expand Down

0 comments on commit 5fa07af

Please sign in to comment.