本文整理匯總了PHP中Buzz\Browser::getLastResponse方法的典型用法代碼示例。如果您正苦於以下問題:PHP Browser::getLastResponse方法的具體用法?PHP Browser::getLastResponse怎麽用?PHP Browser::getLastResponse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Buzz\Browser
的用法示例。
在下文中一共展示了Browser::getLastResponse方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getLatestResponseHeaders
/**
* {@inheritdoc}
*/
public function getLatestResponseHeaders()
{
if (null === ($response = $this->browser->getLastResponse())) {
return;
}
return ['reset' => (int) $response->getHeader('RateLimit-Reset'), 'remaining' => (int) $response->getHeader('RateLimit-Remaining'), 'limit' => (int) $response->getHeader('RateLimit-Limit')];
}
示例2: getResponseStatus
protected function getResponseStatus()
{
$headers = $this->browser->getLastResponse()->getHeaders();
foreach ($headers as $header) {
if (substr($header, 0, 6) == 'Status') {
return (int) substr($header, 8, 3);
}
}
}
示例3: getLastResponse
public function getLastResponse()
{
if ($this->fromCache) {
return $this->data['response'];
}
return parent::getLastResponse();
}
示例4: delete
/**
* Common delete request for all API calls
*
* @param string $resource The path to the resource wanted. For example v2/room
*
* @return array Decoded array containing response
* @throws Exception\RequestException
*/
public function delete($resource)
{
$url = $this->baseUrl . $resource;
$headers = array('Authorization' => $this->auth->getCredential());
$response = $this->browser->delete($url, $headers);
if ($this->browser->getLastResponse()->getStatusCode() > 299) {
throw new RequestException(json_decode($this->browser->getLastResponse()->getContent(), true));
}
return json_decode($response->getContent(), true);
}
示例5: iSubmitDataTo
/**
* @When /^I submit "([^"]*)" data to "([^"]*)"$/
* @param string $pageUrl
* @return void
* @throws \Exception
*/
public function iSubmitDataTo($dataKey, $pageUrl)
{
$this->responseData = $this->responseDecodeException = null;
$this->responseIsJson = false;
if ($this->access_token) {
$this->headers['Authorization'] = 'Bearer ' . $this->access_token;
}
$this->client->submit($this->processPageUrl($pageUrl), array($dataKey => $this->collectedData[$dataKey]), strtolower($this->requestMethod), $this->headers);
$this->response = $this->client->getLastResponse();
}
示例6: put
public function put($resource, $content)
{
$curl = new Curl();
$browser = new Browser($curl);
$url = $this->baseUrl . $resource;
$headers = array('Content-Type' => 'application/json', 'Authorization' => $this->auth->getCredential());
$response = $browser->put($url, $headers, json_encode($content));
if ($browser->getLastResponse()->getStatusCode() > 299) {
throw new BadRequestException($response);
}
return json_decode($response->getContent(), true);
}
示例7: echoLastResponse
/**
* @Then /^echo last response$/
*
* Echos the last response for debugging purposes
* -
* Example:
* And echo last response
*/
public function echoLastResponse()
{
$response = $this->client->getLastResponse();
$headerString = '';
foreach ($response->getHeaders() as $header) {
$headerString = sprintf("%s%s\n", $headerString, $header);
}
echo rtrim($headerString, "\n");
if (empty($response->getContent()) === false) {
echo sprintf("\nContent: %s", $response->getContent());
}
}
示例8: theResponseShouldContainJson
/**
* Checks that response body contains JSON from PyString.
*
* @param PyStringNode $jsonString
*
* @Then /^(?:the )?response should contain json:$/
*/
public function theResponseShouldContainJson(PyStringNode $jsonString)
{
$etalon = json_decode($this->replacePlaceHolder($jsonString->getRaw()), true);
$actual = json_decode($this->browser->getLastResponse()->getContent(), true);
if (null === $etalon) {
throw new \RuntimeException("Can not convert etalon to json:\n" . $this->replacePlaceHolder($jsonString->getRaw()));
}
assertCount(count($etalon), $actual);
foreach ($actual as $key => $needle) {
assertArrayHasKey($key, $etalon);
assertEquals($etalon[$key], $actual[$key]);
}
}
示例9: baseRequest
/**
* Base method for the api requests of library.
*
* @param string $request The request that can be 'get', 'post', 'put', 'patch' and 'delete'
* @param string $method The api method
* @param array $query QueryString that filters the response
* @param string[] $content The content that contains the payload of the the request
*
* @throws Error when the status code is higher than 226. According to the Wikipedia:
* http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#2xx_Success
*
* @return mixed Decoded array containing response
*/
private function baseRequest($request, $method, $query = [], $content = [])
{
$curl = new Curl();
$browser = new Browser($curl);
$url = $this->baseUrl . '/' . $this->version . $method;
if (count($query) > 0) {
$url .= '?';
}
foreach ($query as $key => $value) {
$url .= $key . '=' . $value . '&';
}
if ($this->authentication === null) {
$response = $browser->{$request}($url, $this->headers);
} elseif (count($content) === 0) {
$response = $browser->{$request}($url . $this->authentication->getAuthAsString());
} else {
$response = $browser->{$request}($url, $this->headers, array_merge($content, $this->authentication->getAuth()));
}
if ($browser->getLastResponse()->getStatusCode() > 226) {
throw new Error(json_decode(gzdecode($browser->getLastResponse()->getContent()), true));
}
return json_decode(gzdecode($response->getContent()), true);
}