芝麻web文件管理V1.00
编辑当前文件:/home/sditechnicalteam/public_html/vendor/craftsys/msg91-php/src/Support/Request.php
httpClient = $httpClient; $this->options = $options; $this->validator = new Validator(); } /** * Get the request payload * * @return array */ protected function getPayload() { return $this->options->toArray(); } protected function validate(array $payload) { $token = $payload['authkey'] ?? ""; if (!$token) { $this->validator->addError('authkey', 'Authkey is required'); } } /** * Send the request and return the response or exception * @return \Craftsys\Msg91\Response|null * @throws \Craftsys\Msg91\Exceptions\ResponseErrorException * |\Craftsys\Msg91\Exceptions\ValidationException * |\GuzzleHttp\Exception\ClientException */ public function handle() { $client = $this->httpClient; $payload = $this->getPayload(); $this->validate($payload); if (!$this->validator->isValid()) { throw new ValidationException('Invalid request parameters', 422, null, $this->validator->errors()); } $method = strtolower($this->method); try { $resp = $client->{$method}($this->url, [ $this->content_type => $payload, "headers" => [ 'authkey' => $payload['authkey'], ] ]); return new Response($resp); } catch (\GuzzleHttp\Exception\ClientException $e) { throw new ResponseErrorException( $e->getMessage(), $e->getCode(), $e, (array) json_decode($e->getResponse()->getBody()->getContents()) ); } } }