当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Http_Response::extractBody方法代码示例

本文整理汇总了PHP中Zend_Http_Response::extractBody方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Http_Response::extractBody方法的具体用法?PHP Zend_Http_Response::extractBody怎么用?PHP Zend_Http_Response::extractBody使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Http_Response的用法示例。


在下文中一共展示了Zend_Http_Response::extractBody方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: talkToNewRelic

 /**
  * Talk to new relic
  * 
  * @param string $restPoint
  * @return string
  */
 public function talkToNewRelic($restPoint)
 {
     $headers = array('x-api-key:' . $this->_api_key);
     $http = new Varien_Http_Adapter_Curl();
     $http->write('GET', 'https://api.newrelic.com/api/v1/accounts/' . $this->_account_Id . '/' . $restPoint . '.xml', '1.1', $headers);
     $response = $http->read();
     $response = Zend_Http_Response::extractBody($response);
     return $response;
 }
开发者ID:Bobspadger,项目名称:NewRelic,代码行数:15,代码来源:Api.php

示例2: sendRequest

 public function sendRequest($request, $parameters = array())
 {
     if (!$this->code || !$this->username || !$this->password) {
         return false;
     }
     if ($request != 'verifyUser' && !$this->session) {
         return false;
     }
     $parameters['sessionKey'] = $this->session;
     $parameters['request'] = $request;
     $parameters['version'] = '1.0';
     $parameters['clientCode'] = $this->code;
     $url = $this->getUrl();
     $http = new Varien_Http_Adapter_Curl();
     $http->setConfig(array('timeout' => 100));
     //        $http->write(Zend_Http_Client::POST, $parameters);
     $http->write(Zend_Http_Client::POST, $url, CURL_HTTP_VERSION_1_0, array(), $parameters);
     $responseBody = Zend_Http_Response::extractBody($http->read());
     $http->close();
     if (Mage::getStoreConfig('eepohs_erply/general/log_requests')) {
         Mage::log("REQUEST URL: " . $url . "\nREQUEST PARAMETERS:\n" . print_r($parameters, true) . "\nRESPONSE:\n" . $responseBody, null, self::REQUEST_LOG);
     }
     //        $http = new Varien_Http_Adapter_Curl();
     //        $config = array('timeout' => 30);
     //
     //        $http->setConfig($config);
     //        $http->write(Zend_Http_Client::POST, $url, '1.0', array(), http_build_query($parameters));
     //        $content = Zend_Http_Response::extractBody($http->read());
     //        print_r(Zend_Http_Response::extractHeaders($http->read()));
     //return $content;
     //        $ch = curl_init();
     //        curl_setopt($ch, CURLOPT_URL, $url);
     //        curl_setopt($ch, CURLOPT_HEADER, 1);
     //        curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
     //        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     //        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
     //        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
     //        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     //        curl_setopt($ch, CURLOPT_POST, true);
     //        curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters);
     //
     //        if (curl_exec($ch) === false)
     //            return false;
     //
     //        $content = curl_multi_getcontent($ch);
     //        curl_close($ch);
     //        list($header1, $header2, $body) = explode("\r\n\r\n", $content, 3);
     return $responseBody;
 }
开发者ID:vaimo,项目名称:Eepohs_Erply,代码行数:49,代码来源:Erply.php

示例3: talkToGateway

 /**
  * Talk to pin gateway
  * 
  * @param array $data
  * @param string $endPoint
  * @return object
  */
 protected function talkToGateway($data, $endPoint, $proto = Zend_Http_Client::POST)
 {
     $url = mage::helper('pinpayments')->getGatewayUrl() . '1/' . $endPoint;
     $secretKey = mage::getStoreConfig('payment/pinpayments/secret_api_key');
     if ($proto == Zend_Http_Client::PUT) {
         $result = exec("curl {$url} -u {$secretKey}: -X PUT -d email={$data['email']} -d card_token={$data['card_token']}", $output, $return_var);
     } else {
         $curl = new ProxiBlue_PinPayments_Varien_Http_Adapter_Curl();
         $curl->setConfig(array('timeout' => 15));
         $curl->setConfig(array('userpwd' => mage::getStoreConfig('payment/pinpayments/secret_api_key') . ":"));
         $curl->write($proto, $url, '1.1', null, $data);
         $curlData = $curl->read();
         $result = Zend_Http_Response::extractBody($curlData);
         $curl->close();
         $result = json_decode($result);
     }
     return $result;
 }
开发者ID:evangao,项目名称:misterwallpaper,代码行数:25,代码来源:Api.php

示例4: testLeadingWhitespaceBody

 /**
  * Make sure a response with some leading whitespace in the response body
  * does not get modified (see ZF-1924)
  *
  */
 public function testLeadingWhitespaceBody()
 {
     $body = Zend_Http_Response::extractBody($this->readResponse('response_leadingws'));
     $this->assertEquals($body, "\r\n\t  \n\r\tx", 'Extracted body is not identical to expected body');
 }
开发者ID:ThorstenSuckow,项目名称:conjoon,代码行数:10,代码来源:ResponseTest.php

示例5: testExtractorsOnInvalidString

 public function testExtractorsOnInvalidString()
 {
     // Try with an empty string
     $response_str = '';
     $this->assertTrue(Zend_Http_Response::extractCode($response_str) === false);
     $this->assertTrue(Zend_Http_Response::extractMessage($response_str) === false);
     $this->assertTrue(Zend_Http_Response::extractVersion($response_str) === false);
     $this->assertTrue(Zend_Http_Response::extractBody($response_str) === '');
     $this->assertTrue(Zend_Http_Response::extractHeaders($response_str) === array());
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:10,代码来源:ResponseTest.php

示例6: sendMessage

 public function sendMessage(Xcom_Xfabric_Model_Message $message, array $options = array())
 {
     $url = $this->prepareUri($message->getTopic());
     Mage::getSingleton('xcom_xfabric/debug')->start('Send Request to ' . $url->getUri(), $message->getTopic(), serialize($message->getHeaders()), isset($options['message_data']) ? $options['message_data'] : '');
     $adapter = $this->_getAdapter();
     $adapter->setConfig($this->_config);
     $adapter->write(Zend_Http_Client::POST, $url, '1.1', $this->_prepareHeaders($message->getHeaders()), $message->getBody());
     $result = $adapter->read();
     $error = '';
     $httpCode = $adapter->getInfo(CURLINFO_HTTP_CODE);
     if ($adapter->getErrno()) {
         $error = $adapter->getError();
     }
     if (!$result || $error) {
         Mage::getSingleton('xcom_xfabric/debug')->stop('Unable to complete the request.', $message->getTopic(), $result, 'Unable to complete the request. ' . $error);
         switch ($httpCode) {
             case '400':
                 $errorText = 'Bad request. ';
                 break;
             case '401':
                 $errorText = 'Request is unauthorized. ';
                 break;
             case '403':
                 $errorText = 'Request is forbidden. ';
                 break;
             case '404':
                 $errorText = 'Not Found. ';
                 break;
             case '413':
                 $errorText = 'Message is too large';
                 break;
             default:
                 $errorText = '';
                 break;
         }
         throw Mage::exception('Xcom_Xfabric', Mage::helper('xcom_xfabric')->__('Unable to complete the request. ') . $errorText . $error);
     }
     $zendHttpCode = Zend_Http_Response::extractCode($result);
     $zendHttpMessage = Zend_Http_Response::extractMessage($result);
     $zendHttpBody = Zend_Http_Response::extractBody($result);
     if ($zendHttpCode != '200') {
         Mage::getSingleton('xcom_xfabric/debug')->stop('Unable to complete the request.', $message->getTopic(), $result, $zendHttpMessage . ' ' . $zendHttpBody);
         throw Mage::exception('Xcom_Xfabric', $zendHttpMessage . ' ' . $zendHttpBody, $zendHttpCode);
     }
     if (!empty($options['synchronous']) && !$error) {
         $response = $this->_getResponseMessage($message->getCorrelationId());
         if (!$response) {
             Mage::getSingleton('xcom_xfabric/debug')->stop('Response is not received', $message->getTopic(), $result, 'No Errors');
             throw Mage::exception('Xcom_Xfabric', Mage::helper('xcom_xfabric')->__('Unable to complete the request. Please refer to the User Guide ' . 'to verify your settings and try again. If the error persists, contact your administrator.'));
         }
         return $response;
     }
     Mage::getSingleton('xcom_xfabric/debug')->stop('No Response is been waiting', $message->getTopic(), $result, $error);
     return true;
 }
开发者ID:ridhoq,项目名称:mxpi-twitter,代码行数:55,代码来源:Xfabric.php

示例7: talkToNewRelic

 /**
  * Talk to NewRelic API
  * 
  * @param array $data
  * @return string
  */
 public function talkToNewRelic($data)
 {
     $headers = array('x-api-key:' . $this->_api_key);
     $http = new Varien_Http_Adapter_Curl();
     $http->write('POST', 'https://rpm.newrelic.com/deployments.xml', '1.1', $headers, $data);
     $response = $http->read();
     $response = Zend_Http_Response::extractBody($response);
     return $response;
 }
开发者ID:Bobspadger,项目名称:NewRelic,代码行数:15,代码来源:Abstract.php

示例8: testLeadingWhitespaceBody

 /**
  * Make sure a response with some leading whitespace in the response body
  * does not get modified (see ZF-1924)
  *
  */
 public function testLeadingWhitespaceBody()
 {
     $message = file_get_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'response_leadingws');
     $body = Zend_Http_Response::extractBody($message);
     $this->assertEquals($body, "\r\n\t  \n\r\tx", 'Extracted body is not identical to expected body');
 }
开发者ID:crodriguezn,项目名称:crossfit-milagro,代码行数:11,代码来源:ResponseTest.php

示例9: createApiGet

 public function createApiGet($path, $timeout = self::DEFAULT_TIMEOUT)
 {
     try {
         $config = array('timeout' => $timeout);
         $http = new Varien_Http_Adapter_Curl();
         $feed_url = self::YOTPO_UNSECURED_API_URL . "/" . $path;
         $http->setConfig($config);
         $http->write(Zend_Http_Client::GET, $feed_url, '1.1', array('Content-Type: application/json'));
         $resData = $http->read();
         return array("code" => Zend_Http_Response::extractCode($resData), "body" => json_decode(Zend_Http_Response::extractBody($resData)));
     } catch (Exception $e) {
         Mage::log('error: ' . $e);
     }
 }
开发者ID:buttasg,项目名称:cowgirlk,代码行数:14,代码来源:ApiClient.php


注:本文中的Zend_Http_Response::extractBody方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。