post($uri, [ 'json' => $params, 'headers' => self::getXEfpsHeaders($sign), ]); Log::info('request:', $params, 'efps'); $body = (string)$response->getBody(); Log::info('response:' . $body, [], 'efps'); $result = json_decode($body, true); if (empty($result)) { $result = [ 'returnCode' => '9999', 'returnMsg' => '返回数据异常', ]; } return new Result($result); } catch (\Exception $e) { Log::error('error:' . $e->getMessage(), [], 'efps'); return new Result([ 'returnCode' => '9998', 'returnMsg' => '网络错误', ]); } } protected static function getClient(): Client { if (!self::$client) { self::$client = new Client([ 'base_uri' => self::getConfig('baseUrl'), 'handler' => HandlerStack::create(new CoroutineHandler()), 'timeout' => 20, 'swoole' => [ 'timeout' => 20, 'socket_buffer_size' => 1024 * 1024 * 2, ], ]); } return self::$client; } protected static function getXEfpsHeaders($sign) { return [ 'x-efps-sign-no' => self::getConfig('signNo'), 'x-efps-sign-type' => 'SHA256withRSA', 'x-efps-sign' => $sign, 'x-efps-timestamp' => date('YmdHis') ]; } }