PHP_api接口教程(6)
发布时间:2021-06-06
发布时间:2021-06-06
{
$localIp = isset($_SERVER["SERVER_ADDR"]) ? $_SERVER["SERVER_ADDR"] :
"CLI";
$logger = new LtLogger; $logger->conf["log_file"]
=
rtrim(TOP_SDK_WORK_DIR,
'\\/')
.
'/'
.
"logs/top_comm_err_" . $this->appkey . "_" . date("Y-m-d") . ".log";
$logger->conf["separator"] = "^_^"; $logData = array( date("Y-m-d H:i:s"), $apiName, $this->appkey, $localIp, PHP_OS, $this->sdkVersion, $requestUrl, $errorCode,
str_replace("\n","",$responseTxt) );
$logger->log($logData); }
public function execute($request, $session = null) {
if($this->checkRequest) {
try {
$request->check(); } catch (Exception $e) {
$result->code = $e->getCode(); $result->msg = $e->getMessage(); return $result; } }
//组装系统参数
$sysParams["app_key"] = $this->appkey; $sysParams["v"] = $this->apiVersion; $sysParams["format"] = $this->format;
$sysParams["sign_method"] = $this->signMethod; $sysParams["method"] = $request->getApiMethodName(); $sysParams["timestamp"] = date("Y-m-d H:i:s");