本文整理汇总了PHP中GuzzleHttp\Message\Response::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::__construct方法的具体用法?PHP Response::__construct怎么用?PHP Response::__construct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GuzzleHttp\Message\Response
的用法示例。
在下文中一共展示了Response::__construct方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(RequestInterface $pRequest)
{
/** url parsing "formula" for resource */
list(, $subscription, $format, , $season, $week) = explode('/', $pRequest->getPath());
$file_partial = __DIR__ . '/' . implode('.', [$subscription, $format, $season, $week]);
$headers = (include $file_partial . '.header.php');
$response_code = explode(' ', $headers[0])[1];
$mocked_response = file_get_contents($file_partial . '.body.' . $format);
$stream = Stream\Stream::factory($mocked_response);
parent::__construct($response_code, $headers, $stream);
}
示例2:
/**
* @param \GuzzleHttp\Message\Response $response
*/
function __construct($response)
{
parent::__construct($response->getStatusCode(), $response->getHeaders(), $response->getBody());
$jsonBody = $this->json();
if (array_key_exists("code", $jsonBody)) {
$this->internal_code = $jsonBody["code"];
$this->internal_message = $jsonBody["message"];
$this->internal_type = $jsonBody["type"];
}
if (array_key_exists("atoken", $jsonBody) || array_key_exists("uid", $jsonBody)) {
$this->internal_code = 200;
$this->internal_type = $jsonBody["type"] = "oauthResponse";
}
}
示例3: __construct
/**
* @param int|string $statusCode The response status code (e.g. 200)
* @param array $headers The response headers
* @param StreamInterface $body The body of the response
* @param array $options Response message options
* - reason_phrase: Set a custom reason phrase
* - protocol_version: Set a custom protocol version
*/
public function __construct($statusCode, array $headers = [], StreamInterface $body = null, array $options = [])
{
parent::__construct($statusCode, $headers, $body, $options);
}