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