|
|
|
@ -5,7 +5,7 @@ namespace Base\Tool\GameResource;
|
|
|
|
|
use Base\Tool\Log;
|
|
|
|
|
use Exception;
|
|
|
|
|
use GuzzleHttp\Client;
|
|
|
|
|
use GuzzleHttp\Exception\RequestException;
|
|
|
|
|
use Think\Log as ThinkLog;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 御剑灵域-测试资源接口
|
|
|
|
@ -51,14 +51,14 @@ class YjlyClient
|
|
|
|
|
return $this->request($api, $params);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
$env = C('APP_ENV', null, 'prod');
|
|
|
|
|
Log::error('Yjly ' . $e->getMessage());
|
|
|
|
|
$this->log($e->getMessage(), ThinkLog::ERR);
|
|
|
|
|
return ['status' => 0, 'msg' => '接口请求错误。' . ($env == 'prod' ? '' : $e->getMessage()) , 'data' => []];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function request($api, $params)
|
|
|
|
|
{
|
|
|
|
|
Log::info('Yjly-params: ' . json_encode($params));
|
|
|
|
|
$this->log('params: ' . json_encode($params));
|
|
|
|
|
if ($api['method'] == 'get') {
|
|
|
|
|
return $this->get($api['uri'], $params);
|
|
|
|
|
} else {
|
|
|
|
@ -73,7 +73,7 @@ class YjlyClient
|
|
|
|
|
'form_params' => $params,
|
|
|
|
|
]);
|
|
|
|
|
$result = (string)$response->getBody();
|
|
|
|
|
Log::info('Yjly-response: ' . $result);
|
|
|
|
|
$this->log('response: ' . $result);
|
|
|
|
|
return json_decode($result, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -84,7 +84,7 @@ class YjlyClient
|
|
|
|
|
'query' => $params,
|
|
|
|
|
]);
|
|
|
|
|
$result = (string)$response->getBody();
|
|
|
|
|
Log::info('Yjly-response: ' . $result);
|
|
|
|
|
$this->log('response: ' . $result);
|
|
|
|
|
return json_decode($result, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -105,7 +105,7 @@ class YjlyClient
|
|
|
|
|
$signString .= $params['orderNum'];
|
|
|
|
|
$signString .= $params['time'];
|
|
|
|
|
$signString .= self::SIGN_KEY;
|
|
|
|
|
Log::info('Yjly-signString: ' . $signString);
|
|
|
|
|
$this->log('signString: ' . $signString);
|
|
|
|
|
return md5($signString);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -223,4 +223,8 @@ class YjlyClient
|
|
|
|
|
{
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function log($message, $level = ThinkLog::INFO) {
|
|
|
|
|
Log::write($message, $level, 'game_api/yjly');
|
|
|
|
|
}
|
|
|
|
|
}
|