當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Browser::getLastResponse方法代碼示例

本文整理匯總了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')];
 }
開發者ID:softr,項目名稱:asaas-php-sdk,代碼行數:10,代碼來源:BuzzAdapter.php

示例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);
         }
     }
 }
開發者ID:moein,項目名稱:zendesk-ticket-manager,代碼行數:9,代碼來源:TicketManager.php

示例3: getLastResponse

 public function getLastResponse()
 {
     if ($this->fromCache) {
         return $this->data['response'];
     }
     return parent::getLastResponse();
 }
開發者ID:ivoba,項目名稱:buzzle,代碼行數:7,代碼來源:Browser.php

示例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);
 }
開發者ID:Andrewpk,項目名稱:jenkinsFailReminder,代碼行數:18,代碼來源:Client.php

示例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();
 }
開發者ID:kartoffelkage,項目名稱:Newscoop,代碼行數:16,代碼來源:RestContext.php

示例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);
 }
開發者ID:productsupcom,項目名稱:JiraApiClient,代碼行數:12,代碼來源:Client.php

示例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());
     }
 }
開發者ID:kielabokkie,項目名稱:jsonapi-behat-extension,代碼行數:20,代碼來源:JsonApiContext.php

示例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]);
     }
 }
開發者ID:a2xchip,項目名稱:pim-community-dev,代碼行數:20,代碼來源:WebApiContext.php

示例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);
 }
開發者ID:schmunk42,項目名稱:StackExchangeApiClient,代碼行數:36,代碼來源:Client.php


注:本文中的Buzz\Browser::getLastResponse方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。