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


PHP Zend_Http_Response::getBody方法代碼示例

本文整理匯總了PHP中Zend_Http_Response::getBody方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Http_Response::getBody方法的具體用法?PHP Zend_Http_Response::getBody怎麽用?PHP Zend_Http_Response::getBody使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend_Http_Response的用法示例。


在下文中一共展示了Zend_Http_Response::getBody方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testAppendBody

 public function testAppendBody()
 {
     $expected = 'content for the response body';
     $this->_response->setBody($expected);
     $additional = '; and then there was more';
     $this->_response->appendBody($additional);
     $this->assertEquals($expected . $additional, $this->_response->getBody());
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:8,代碼來源:HttpTest.php

示例2: formatResponse

 /** Set up the response rendering
  * 
  * @param string $response
  */
 public function formatResponse(Zend_Http_Response $response)
 {
     if ('json' === $this->getResponseType()) {
         return json_decode($response->getBody());
     } else {
         return new Zend_Rest_Client_Result($response->getBody());
     }
 }
開發者ID:rwebley,項目名稱:Beowulf---PAS,代碼行數:12,代碼來源:Place.php

示例3: run

 public function run()
 {
     if ($this->debugMode) {
         echo "Restricting crawl to {$this->domain}\n";
     }
     //loop across available items in the queue of pages to crawl
     while (!$this->queue->isEmpty()) {
         if (isset($this->limit) && $this->counter >= $this->limit) {
             break;
         }
         $this->counter++;
         //get a new url to crawl
         $url = $this->queue->pop();
         if ($this->debugMode) {
             echo "Queue Length: " . $this->queue->queueLength() . "\n";
             echo "Crawling " . $url . "\n";
         }
         //set the url into the http client
         $this->client->setUri($url);
         //make the request to the remote server
         $this->currentResponse = $this->client->request();
         //don't bother trying to parse this if it's not text
         if (stripos($this->currentResponse->getHeader('Content-type'), 'text') === false) {
             continue;
         }
         //search for <a> tags in the document
         $body = $this->currentResponse->getBody();
         $linksQuery = new Zend_Dom_Query($body);
         $links = $linksQuery->query('a');
         if ($this->debugMode) {
             echo "\tFound " . count($links) . " links...\n";
         }
         foreach ($links as $link) {
             //get the href of the link and find out if it links to the current host
             $href = $link->getAttribute('href');
             $urlparts = parse_url($href);
             if ($this->stayOnDomain && isset($urlparts["host"]) && $urlparts["host"] != $this->domain) {
                 continue;
             }
             //if it's an absolute link without a domain or a scheme, attempt to fix it
             if (!isset($urlparts["host"])) {
                 $href = 'http://' . $this->domain . $href;
                 //this is a really naive way of doing this!
             }
             //push this link into the queue to be crawled
             $this->queue->push($href);
         }
         //for each page that we see, run every registered task across it
         foreach ($this->tasks as $task) {
             $task->task($this->currentResponse, $this->client);
         }
     }
     //after we're done with everything, call the shutdown hook on all the tasks
     $this->shutdownTasks();
 }
開發者ID:austinphp,項目名稱:crawler,代碼行數:55,代碼來源:Crawler.php

示例4: load

 public function load(\Zend_Http_Response $httpResponse)
 {
     $this->_reset();
     if ($httpResponse->getBody()) {
         set_error_handler(array($this, 'handleLoadErrors'));
         $this->_json = json_decode($httpResponse->getBody());
         restore_error_handler();
     }
     $this->_httpResponse = $httpResponse;
     return $this;
 }
開發者ID:sirprize,項目名稱:rest,代碼行數:11,代碼來源:Json.php

示例5: load

 public function load(\Zend_Http_Response $httpResponse)
 {
     $this->_reset();
     if ($httpResponse->getBody()) {
         set_error_handler(array($this, 'handleLoadErrors'));
         $this->_simpleXml = simplexml_load_string($httpResponse->getBody());
         restore_error_handler();
     }
     $this->_httpResponse = $httpResponse;
     return $this;
 }
開發者ID:sirprize,項目名稱:rest,代碼行數:11,代碼來源:SimpleXml.php

示例6: load

 public function load(\Zend_Http_Response $httpResponse)
 {
     $this->_reset();
     if ($httpResponse->getBody()) {
         set_error_handler(array($this, 'handleLoadErrors'));
         $this->_dom = new \DOMDocument();
         $this->_dom->loadXml($httpResponse->getBody());
         restore_error_handler();
     }
     $this->_httpResponse = $httpResponse;
     return $this;
 }
開發者ID:sirprize,項目名稱:rest,代碼行數:12,代碼來源:Dom.php

示例7: _callApi

 /**
  *
  * @param string $path
  * @param array $options
  */
 protected function _callApi($path, $options)
 {
     $param['format'] = 'json';
     $this->_response = $restClient->restGet($path, $options);
     switch ($param['format']) {
         case 'json':
             $this->_data = json_decode($this->_response->getBody());
             break;
         case 'xml':
             throw new \Thin\Exception('Not yet implemented. Please use json format.');
             break;
     }
     $this->_checkErrors();
     return $this->_data['data'];
 }
開發者ID:schpill,項目名稱:thin,代碼行數:20,代碼來源:Bitly.php

示例8: getDocument

    /**
     * Gets the document object for this response
     *
     * @return DOMDocument the DOM Document for this response.
     */
    public function getDocument()
    {
        try {
            $body = $this->_httpResponse->getBody();
        } catch (\Zend\Http\Exception $e) {
            $body = false;
        }

        if ($this->_document === null) {
            if ($body !== false) {
                // turn off libxml error handling
                $errors = libxml_use_internal_errors();

                $this->_document = new \DOMDocument();
                if (!$this->_document->loadXML($body)) {
                    $this->_document = false;
                }

                // reset libxml error handling
                libxml_clear_errors();
                libxml_use_internal_errors($errors);
            } else {
                $this->_document = false;
            }
        }

        return $this->_document;
    }
開發者ID:niallmccrudden,項目名稱:zf2,代碼行數:33,代碼來源:Response.php

示例9: parseResponse

 /**
  * Parses the JSON encoded request body returned by the Recensus API and 
  * returns a PHP array representing the resourse.
  * 
  * @return array
  */
 protected function parseResponse()
 {
     $parseResult = json_decode($this->lastResponse->getBody(), true);
     if (!$parseResult) {
         $this->handleError("Error decoding response from API.");
     }
     return $parseResult;
 }
開發者ID:recensus,項目名稱:php-sdk,代碼行數:14,代碼來源:Api.php

示例10: parseZendResponse

 /**
  * @param Zend_Http_Response $response
  * @return json string
  * @throws
  */
 public function parseZendResponse(Zend_Http_Response $response)
 {
     if ($response->getStatus() == 200) {
         return $response->getBody();
     } else {
         throw new Exception("Error: Status is: " . $response->getStatus() . " message: " . $response->getMessage());
     }
 }
開發者ID:rwadegaonkar,項目名稱:hobbyhorse,代碼行數:13,代碼來源:Wrapper.php

示例11: testClearBody

 public function testClearBody()
 {
     $this->_response->append('some', "some content\n");
     $this->assertTrue($this->_response->clearBody());
     $body = $this->_response->getBody(true);
     $this->assertTrue(is_array($body));
     $this->assertEquals(0, count($body));
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:8,代碼來源:HttpTest.php

示例12: sendRequest

 /**
  * Sends a request and returns a response
  *
  * @param CartRecover_Request $request
  * @return Cart_Recover_Response
  */
 public function sendRequest(CartRecover_Request $request)
 {
     $this->client->setUri($request->getUri());
     $this->client->setParameterGet($request->getParams());
     $this->client->setMethod($request->getMethod());
     $this->client->setHeaders('Accept', 'application/json');
     $this->response = $this->client->request();
     if ($this->response->getHeader('Content-Type') != 'application/json') {
         throw new CartRecover_Exception_UnexpectedValueException("Unknown response format.");
     }
     $body = json_decode($this->response->getBody(), true);
     $response = new CartRecover_Response();
     $response->setRawResponse($this->response->asString());
     $response->setBody($body);
     $response->setHeaders($this->response->getHeaders());
     $response->setStatus($this->response->getMessage(), $this->response->getStatus());
     return $response;
 }
開發者ID:digital-canvas,項目名稱:cart-recover-phpapi,代碼行數:24,代碼來源:Zend.php

示例13: __construct

 /**
  *
  *
  * @param Zend_Http_Response $response JSON response from the PinPayments gateway
  * @throws Dwyera_Pinpay_Model_ResponseParseException If an invalid JSON response object is passed
  */
 public function __construct(Zend_Http_Response $response)
 {
     $this->response = $response;
     $this->httpResponseCode = $response->getStatus();
     $this->msgObj = json_decode($response->getBody());
     if ($this->msgObj == null) {
         throw new Dwyera_Pinpay_Model_ResponseParseException("Could not parse PinPayments gateway response");
     }
 }
開發者ID:andrew-dwyer,項目名稱:PINpayments,代碼行數:15,代碼來源:Result.php

示例14: task

 public function task(Zend_Http_Response $response, Zend_Http_Client $client)
 {
     $query = new Zend_Dom_Query($response->getBody());
     $images = $query->query('img');
     foreach ($images as $image) {
         $this->images[] = $image->getAttribute('src');
     }
     $this->images = array_unique($this->images);
 }
開發者ID:austinphp,項目名稱:crawler,代碼行數:9,代碼來源:FindImagesTask.php

示例15: __construct

 /**
  * base constructor for Response objects
  *
  * @param Zend_Http_Response $response
  */
 public function __construct($response)
 {
     if ($response instanceof Zend_Http_Response) {
         $this->_response = WirecardCEE_Stdlib_SerialApi::decode($response->getBody());
     } elseif (is_array($response)) {
         $this->_response = $response;
     } else {
         throw new WirecardCEE_Stdlib_Exception_InvalidResponseException(sprintf('Invalid response from WirecardCEE thrown in %s.', __METHOD__));
     }
 }
開發者ID:wirecard,項目名稱:magento-wcs,代碼行數:15,代碼來源:ResponseAbstract.php


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