本文整理汇总了PHP中Guzzle\Http\Message\Response::getMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::getMessage方法的具体用法?PHP Response::getMessage怎么用?PHP Response::getMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guzzle\Http\Message\Response
的用法示例。
在下文中一共展示了Response::getMessage方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getResponse
/**
* Get the response of the query.
* Will be the json decoded data if success, else the error message.
*
* @return array|string
*/
public function getResponse()
{
if (false === $this->response->isSuccessful()) {
return $this->response->getMessage();
}
return $this->response->json();
}
示例2: getMessage
/**
* {@inheritdoc}
*/
public function getMessage()
{
try {
$result = $this->response->getMessage();
} catch (\Exception $exception) {
throw GuzzleRestException::createFromException($exception);
}
return $result;
}
示例3: testPingThrowsClientException
/**
* If the server returns an error 400 or above ping throws a PublishServerException
* @group unit
*/
public function testPingThrowsClientException()
{
$errorMessage = "some error";
Phockito::when($this->mockResponse->getMessage())->return($errorMessage);
Phockito::when($this->mockRequest->send())->return($this->mockResponse);
Phockito::when($this->client)->get(anything())->return($this->mockRequest);
for ($errorCode = 400; $errorCode < 506; $errorCode++) {
Phockito::when($this->mockResponse->getStatusCode())->return($errorCode);
try {
$this->client->ping();
$this->fail("Expected PublishServerException");
} catch (PublishServiceClient\Exception\PublishServerException $ex) {
$this->assertEquals("Server error occurred. Error code: " . $errorCode . " Response: " . $errorMessage, $ex->getMessage());
Phockito::reset($this->mockResponse, 'getStatusCode');
}
}
}
示例4: testGetMessage
/**
* @covers Guzzle\Http\Message\Response::getMessage
*/
public function testGetMessage()
{
$response = new Response(200, new Collection(array('Content-Length' => 4)), 'body');
$this->assertEquals("HTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\nbody", $response->getMessage());
}
示例5: processResponse
private function processResponse(Response $response)
{
if (!$response->isSuccessful()) {
throw new ApiServerException($response->getMessage(), $response->getStatusCode());
}
if (self::FORMAT_ARRAY === $this->outputFormat) {
return $response->json();
}
return $response->getBody(true);
}
示例6: __construct
/**
* @param Response $response
*/
public function __construct(Response $response)
{
parent::__construct("Server error occurred. Error code: " . $response->getStatusCode() . " Response: " . $response->getMessage());
}