本文整理汇总了PHP中Buzz\Message\Response::isSuccessful方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::isSuccessful方法的具体用法?PHP Response::isSuccessful怎么用?PHP Response::isSuccessful使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Buzz\Message\Response
的用法示例。
在下文中一共展示了Response::isSuccessful方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(TransportResponse $response)
{
if (!$response->isSuccessful()) {
throw new TransportException($response);
}
$this->response = $response;
}
示例2: rev
public function rev(Response $response)
{
if ($response->isSuccessful()) {
return $this->decode($response->getHeader('Etag'));
}
throw new RugException('not_found', 'The specified document or revision cannot be found or has been deleted');
}
示例3: isSuccessful
public function isSuccessful()
{
if (parent::isSuccessful()) {
$result = $this->getArrayResult();
return !array_key_exists('error', $result);
}
return false;
}
示例4: doRequest
/**
* @param FormRequest $request
*
* @throws HttpException
*
* @return array
*/
protected function doRequest(FormRequest $request)
{
$request->setMethod('POST');
$request->fromUrl($this->getApiEndpoint());
$this->client->send($request, $response = new Response());
if (false == $response->isSuccessful()) {
throw HttpException::factory($request, $response);
}
$result = array();
parse_str($response->getContent(), $result);
foreach ($result as &$value) {
$value = urldecode($value);
}
return $result;
}
示例5: assertRequestIsSuccessful
/**
* @param \Buzz\Message\Response $response
* @throws \InvalidArgumentException
*/
private function assertRequestIsSuccessful(\Buzz\Message\Response $response)
{
$data = json_decode($response->getContent(), true);
if (!$response->isSuccessful() || !isset($data['success']) || $data['success'] != "true") {
//XXX Invent Exception fitting here
throw new \InvalidArgumentException($response->getContent());
}
}
示例6: getResult
/**
* @param \Buzz\Message\Response $response
*
* @throws HttpException if status not OK
* @throws HttpException if content not json
*
* @return \stdClass|\stdClass[]|null
*/
protected function getResult(Response $response)
{
if (false == $response->isSuccessful()) {
throw new HttpException($response->getStatusCode(), sprintf("The api call finished with status %s but it was expected 200. Response content:\n\n%s", $response->getStatusCode(), $response->getContent()));
}
$content = $response->getContent();
$result = null;
if (false == empty($content)) {
$result = json_decode($response->getContent());
if (null === $result) {
throw new LogicException(sprintf("The response status is successful but the content is not a valid json object:\n\n%s", $response->getContent()));
}
}
return $result;
}
示例7: handleResponse
/**
* @param Response $response
*
* @throws HttpException
*/
protected function handleResponse(Response $response)
{
if ($response->isSuccessful()) {
return;
}
$this->handleError($response);
}
示例8: isSuccessful
/**
* @return bool
*/
public function isSuccessful()
{
return $this->response->isSuccessful();
}