当前位置: 首页>>代码示例>>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;未经允许,请勿转载。