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


PHP Zend_Http_Client_Adapter_Interface类代码示例

本文整理汇总了PHP中Zend_Http_Client_Adapter_Interface的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Http_Client_Adapter_Interface类的具体用法?PHP Zend_Http_Client_Adapter_Interface怎么用?PHP Zend_Http_Client_Adapter_Interface使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: _postBack

 /**
  * Post back to PayPal to check whether this request is a valid one
  *
  * @param  Zend_Http_Client_Adapter_Interface $httpAdapter
  * @throws Exception
  */
 protected function _postBack(Zend_Http_Client_Adapter_Interface $httpAdapter)
 {
     $sReq = '';
     foreach ($this->_request as $k => $v) {
         $sReq .= '&' . $k . '=' . urlencode(stripslashes($v));
     }
     $sReq .= "&cmd=_notify-validate";
     $sReq = substr($sReq, 1);
     $this->_debugData['postback'] = $sReq;
     $this->_debugData['postback_to'] = $this->_config->getPaypalUrl();
     $httpAdapter->write(Zend_Http_Client::POST, $this->_config->getPaypalUrl(), '1.1', array(), $sReq);
     try {
         $response = $httpAdapter->read();
     } catch (Exception $e) {
         $this->_debugData['http_error'] = array('error' => $e->getMessage(), 'code' => $e->getCode());
         throw $e;
     }
     $this->_debugData['postback_result'] = $response;
     // =====================================================================
     // Changed from default code.  Paypal now regularly returns a 100
     // response with an empty body followed by a 200 response with the
     // VERIFIED/INVALID message.  The code below will check the last
     // response for the VERIFIED/INVALID code rather than the first.
     //
     // ref: http://www.dhmedia.com.au/blog/debugging-paypal-ipn-postback-failure-magent
     // Magento 2 Pull Request: https://github.com/magento/magento2/pull/136
     $response = preg_split('/^\\r?$/m', $response);
     $response = trim(end($response));
     // =====================================================================
     if ($response != 'VERIFIED') {
         throw new Exception('PayPal IPN postback failure. See ' . self::DEFAULT_LOG_FILE . ' for details.');
     }
     unset($this->_debugData['postback'], $this->_debugData['postback_result']);
 }
开发者ID:LybeAB,项目名称:Magento-Paypalfixes,代码行数:40,代码来源:Ipn.php

示例2: loadAdapter

 /**
  * Load the connection adapter
  * 
  * While this method is not called more than one for a client, it is 
  * seperated from ->request() to preserve logic and readability
  *
  * @param Zend_Http_Client_Adapter_Interface|string $adapter
  */
 protected function loadAdapter($adapter)
 {
     if (is_string($adapter)) {
         try {
             Zend_Loader::loadClass($adapter);
         } catch (Zend_Exception $e) {
             throw new Zend_Http_Client_Exception("Unable to load adapter '{$adapter}': {$e->getMessage()}");
         }
         $adapter = new $adapter();
     }
     if (!$adapter instanceof Zend_Http_Client_Adapter_Interface) {
         throw new Zend_Http_Client_Exception('Passed adapter is not a HTTP connection adapter');
     }
     $this->adapter = $adapter;
     $config = $this->config;
     unset($config['adapter']);
     $this->adapter->setConfig($config);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:26,代码来源:Client.php

示例3: _postBack

 /**
  * Post back to PayPal to check whether this request is a valid one
  *
  * @param Zend_Http_Client_Adapter_Interface $httpAdapter
  */
 protected function _postBack(Zend_Http_Client_Adapter_Interface $httpAdapter)
 {
     $postbackQuery = http_build_query($this->_request) . '&cmd=_notify-validate';
     $postbackUrl = $this->_config->getPaypalUrl();
     $this->_debugData['postback_to'] = $postbackUrl;
     $httpAdapter->setConfig(array('verifypeer' => $this->_config->verifyPeer));
     $httpAdapter->write(Zend_Http_Client::POST, $postbackUrl, '1.1', array('Connection: close'), $postbackQuery);
     try {
         $postbackResult = $httpAdapter->read();
     } catch (Exception $e) {
         $this->_debugData['http_error'] = array('error' => $e->getMessage(), 'code' => $e->getCode());
         throw $e;
     }
     $response = preg_split('/^\\r?$/m', $postbackResult, 2);
     $response = trim($response[1]);
     if ($response != 'VERIFIED') {
         $this->_debugData['postback'] = $postbackQuery;
         $this->_debugData['postback_result'] = $postbackResult;
         throw new Exception('PayPal IPN postback failure. See ' . self::DEFAULT_LOG_FILE . ' for details.');
     }
 }
开发者ID:SalesOneGit,项目名称:s1_magento,代码行数:26,代码来源:Ipn.php

示例4: _postBack

 /**
  * Post back to PayPal to check whether this request is a valid one
  *
  * @param Zend_Http_Client_Adapter_Interface $httpAdapter
  */
 protected function _postBack(Zend_Http_Client_Adapter_Interface $httpAdapter)
 {
     $postbackQuery = http_build_query($this->_request) . '&cmd=_notify-validate';
     $postbackUrl = $this->_config->getPaypalUrl();
     $this->_debugData['postback_to'] = $postbackUrl;
     $httpAdapter->setConfig(array('verifypeer' => $this->_config->verifyPeer));
     $httpAdapter->write(Zend_Http_Client::POST, $postbackUrl, '1.1', array('Connection: close'), $postbackQuery);
     try {
         $postbackResult = $httpAdapter->read();
     } catch (Exception $e) {
         $this->_debugData['http_error'] = array('error' => $e->getMessage(), 'code' => $e->getCode());
         throw $e;
     }
     /*
      * Handle errors on PayPal side.
      */
     $responseCode = Zend_Http_Response::extractCode($postbackResult);
     if (empty($postbackResult) || in_array($responseCode, array('500', '502', '503'))) {
         if (empty($postbackResult)) {
             $reason = 'Empty response.';
         } else {
             $reason = 'Response code: ' . $responseCode . '.';
         }
         $this->_debugData['exception'] = 'PayPal IPN postback failure. ' . $reason;
         throw new Mage_Paypal_UnavailableException($reason);
     }
     $response = preg_split('/^\\r?$/m', $postbackResult, 2);
     $response = trim($response[1]);
     if ($response != 'VERIFIED') {
         $this->_debugData['postback'] = $postbackQuery;
         $this->_debugData['postback_result'] = $postbackResult;
         throw new Exception('PayPal IPN postback failure. See ' . self::DEFAULT_LOG_FILE . ' for details.');
     }
 }
开发者ID:quyip8818,项目名称:Mag,代码行数:39,代码来源:Ipn.php

示例5: _postBack

 /**
  * Post back to PayPal to check whether this request is a valid one
  *
  * @param Zend_Http_Client_Adapter_Interface $httpAdapter
  */
 protected function _postBack(Zend_Http_Client_Adapter_Interface $httpAdapter)
 {
     $sReq = '';
     foreach ($this->_request as $k => $v) {
         $sReq .= '&' . $k . '=' . urlencode(stripslashes($v));
     }
     $sReq .= "&cmd=_notify-validate";
     $sReq = substr($sReq, 1);
     $this->_debugData['postback'] = $sReq;
     $this->_debugData['postback_to'] = $this->_config->getPaypalUrl();
     $httpAdapter->write(Zend_Http_Client::POST, $this->_config->getPaypalUrl(), '1.1', array(), $sReq);
     try {
         $response = $httpAdapter->read();
     } catch (Exception $e) {
         $this->_debugData['http_error'] = array('error' => $e->getMessage(), 'code' => $e->getCode());
         throw $e;
     }
     $this->_debugData['postback_result'] = $response;
     $response = preg_split('/^\\r?$/m', $response, 2);
     $response = trim($response[1]);
     if ($response != 'VERIFIED') {
         throw new Exception('PayPal IPN postback failure. See ' . self::DEFAULT_LOG_FILE . ' for details.');
     }
     unset($this->_debugData['postback'], $this->_debugData['postback_result']);
 }
开发者ID:njaeger,项目名称:magento_github,代码行数:30,代码来源:Ipn.php

示例6: setClientAdapter

 /**
  * Set adapter for client
  *
  * @param  array $client
  * @return Zend_Auth_Adapter_Cas
  */
 public function setClientAdapter($client = array())
 {
     extract($client);
     $adapter = isset($adapter) ? $adapter : 'Zend_Http_Client_Adapter_Socket';
     $options = isset($options) ? $options : array();
     $this->_clientAdapter = new $adapter();
     $this->_clientAdapter->setConfig($options);
     return $this;
 }
开发者ID:BGCX262,项目名称:zym-svn-to-git,代码行数:15,代码来源:Cas.php

示例7: request

 /**
  * Send the HTTP request and return an HTTP response object
  *
  * @param string $method
  * @return Zend_Http_Response
  * @throws Zend_Http_Client_Exception
  */
 public function request($method = null)
 {
     if (!$this->uri instanceof Zend_Uri_Http) {
         /** @see Zend_Http_Client_Exception */
         require_once 'Zend/Http/Client/Exception.php';
         throw new Zend_Http_Client_Exception('No valid URI has been passed to the client');
     }
     if ($method) {
         $this->setMethod($method);
     }
     $this->redirectCounter = 0;
     $response = null;
     // Make sure the adapter is loaded
     if ($this->adapter == null) {
         $this->setAdapter($this->config['adapter']);
     }
     // Send the first request. If redirected, continue.
     do {
         // Clone the URI and add the additional GET parameters to it
         $uri = clone $this->uri;
         if (!empty($this->paramsGet)) {
             $query = $uri->getQuery();
             if (!empty($query)) {
                 $query .= '&';
             }
             $query .= http_build_query($this->paramsGet, null, '&');
             if ($this->config['rfc3986_strict']) {
                 $query = str_replace('+', '%20', $query);
             }
             // @see ZF-11671 to unmask for some services to foo=val1&foo=val2
             if ($this->getUnmaskStatus()) {
                 if ($this->_queryBracketsEscaped) {
                     $query = preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=', $query);
                 } else {
                     $query = preg_replace('/\\[(?:[0-9]|[1-9][0-9]+)\\]=/', '=', $query);
                 }
             }
             $uri->setQuery($query);
         }
         $body = $this->_prepareBody();
         $headers = $this->_prepareHeaders();
         // check that adapter supports streaming before using it
         if (is_resource($body) && !$this->adapter instanceof Zend_Http_Client_Adapter_Stream) {
             /** @see Zend_Http_Client_Exception */
             require_once 'Zend/Http/Client/Exception.php';
             throw new Zend_Http_Client_Exception('Adapter does not support streaming');
         }
         // Open the connection, send the request and read the response
         $this->adapter->connect($uri->getHost(), $uri->getPort(), $uri->getScheme() == 'https' ? true : false);
         if ($this->config['output_stream']) {
             if ($this->adapter instanceof Zend_Http_Client_Adapter_Stream) {
                 $stream = $this->_openTempStream();
                 $this->adapter->setOutputStream($stream);
             } else {
                 /** @see Zend_Http_Client_Exception */
                 require_once 'Zend/Http/Client/Exception.php';
                 throw new Zend_Http_Client_Exception('Adapter does not support streaming');
             }
         }
         $this->last_request = $this->adapter->write($this->method, $uri, $this->config['httpversion'], $headers, $body);
         $response = $this->adapter->read();
         if (!$response) {
             /** @see Zend_Http_Client_Exception */
             require_once 'Zend/Http/Client/Exception.php';
             throw new Zend_Http_Client_Exception('Unable to read response, or response is empty');
         }
         if ($this->config['output_stream']) {
             $streamMetaData = stream_get_meta_data($stream);
             if ($streamMetaData['seekable']) {
                 rewind($stream);
             }
             // cleanup the adapter
             $this->adapter->setOutputStream(null);
             $response = Zend_Http_Response_Stream::fromStream($response, $stream);
             $response->setStreamName($this->_stream_name);
             if (!is_string($this->config['output_stream'])) {
                 // we used temp name, will need to clean up
                 $response->setCleanup(true);
             }
         } else {
             $response = Zend_Http_Response::fromString($response);
         }
         if ($this->config['storeresponse']) {
             $this->last_response = $response;
         }
         // Load cookies into cookie jar
         if (isset($this->cookiejar)) {
             $this->cookiejar->addCookiesFromResponse($response, $uri, $this->config['encodecookies']);
         }
         // If we got redirected, look for the Location header
         if ($response->isRedirect() && ($location = $response->getHeader('location'))) {
             // Avoid problems with buggy servers that add whitespace at the
             // end of some headers (See ZF-11283)
//.........这里部分代码省略.........
开发者ID:abdulhadikaryana,项目名称:kebudayaan,代码行数:101,代码来源:Client.php

示例8: request

 /**
  * Send the HTTP request and return an HTTP response object
  *
  * @param string $method
  * @return Zend_Http_Response
  * @throws Zend_Http_Client_Exception
  */
 public function request($method = null)
 {
     if (!$this->uri instanceof Zend_Uri_Http) {
         /** @see Zend_Http_Client_Exception */
         require_once 'Zend/Http/Client/Exception.php';
         throw new Zend_Http_Client_Exception('No valid URI has been passed to the client');
     }
     if ($method) {
         $this->setMethod($method);
     }
     $this->redirectCounter = 0;
     $response = null;
     // Make sure the adapter is loaded
     if ($this->adapter == null) {
         $this->setAdapter($this->config['adapter']);
     }
     // Send the first request. If redirected, continue.
     do {
         // Clone the URI and add the additional GET parameters to it
         $uri = clone $this->uri;
         if (!empty($this->paramsGet)) {
             $query = $uri->getQuery();
             if (!empty($query)) {
                 $query .= '&';
             }
             $query .= http_build_query($this->paramsGet, null, '&');
             $uri->setQuery($query);
         }
         $body = $this->_prepareBody();
         $headers = $this->_prepareHeaders();
         // Open the connection, send the request and read the response
         $this->adapter->connect($uri->getHost(), $uri->getPort(), $uri->getScheme() == 'https' ? true : false);
         $this->last_request = $this->adapter->write($this->method, $uri, $this->config['httpversion'], $headers, $body);
         $response = $this->adapter->read();
         if (!$response) {
             /** @see Zend_Http_Client_Exception */
             require_once 'Zend/Http/Client/Exception.php';
             throw new Zend_Http_Client_Exception('Unable to read response, or response is empty');
         }
         $response = Zend_Http_Response::fromString($response);
         if ($this->config['storeresponse']) {
             $this->last_response = $response;
         }
         // Load cookies into cookie jar
         if (isset($this->cookiejar)) {
             $this->cookiejar->addCookiesFromResponse($response, $uri);
         }
         // If we got redirected, look for the Location header
         if ($response->isRedirect() && ($location = $response->getHeader('location'))) {
             // Check whether we send the exact same request again, or drop the parameters
             // and send a GET request
             if ($response->getStatus() == 303 || !$this->config['strictredirects'] && ($response->getStatus() == 302 || $response->getStatus() == 301)) {
                 $this->resetParameters();
                 $this->setMethod(self::GET);
             }
             // If we got a well formed absolute URI
             if (Zend_Uri_Http::check($location)) {
                 $this->setHeaders('host', null);
                 $this->setUri($location);
             } else {
                 // Split into path and query and set the query
                 if (strpos($location, '?') !== false) {
                     list($location, $query) = explode('?', $location, 2);
                 } else {
                     $query = '';
                 }
                 $this->uri->setQuery($query);
                 // Else, if we got just an absolute path, set it
                 if (strpos($location, '/') === 0) {
                     $this->uri->setPath($location);
                     // Else, assume we have a relative path
                 } else {
                     // Get the current path directory, removing any trailing slashes
                     $path = $this->uri->getPath();
                     $path = rtrim(substr($path, 0, strrpos($path, '/')), "/");
                     $this->uri->setPath($path . '/' . $location);
                 }
             }
             ++$this->redirectCounter;
         } else {
             // If we didn't get any location, stop redirecting
             break;
         }
     } while ($this->redirectCounter < $this->config['maxredirects']);
     return $response;
 }
开发者ID:Mendim,项目名称:gtv-resources,代码行数:93,代码来源:Client.php

示例9: request

 /**
  * Send the HTTP request and return an HTTP response object
  *
  * @param string $method
  * @return Zend_Http_Response
  * @throws Zend_Http_Client_Exception
  */
 public function request($method = null)
 {
     if (!$this->uri instanceof Sabel_Http_Uri) {
         $message = __METHOD__ . "() No valid URI has been passed to the client.";
         throw new Sabel_Exception_Runtime($message);
     }
     if ($method) {
         $this->setMethod($method);
     }
     $this->redirectCounter = 0;
     $response = null;
     // Make sure the adapter is loaded
     if ($this->adapter == null) {
         $this->setAdapter($this->config["adapter"]);
     }
     // Send the first request. If redirected, continue.
     do {
         // Clone the URI and add the additional GET parameters to it
         $uri = clone $this->uri;
         $query = array();
         if (!empty($uri->query)) {
             parse_str($uri->query, $query);
         }
         if (!empty($this->paramsGet)) {
             $query = array_merge($query, $this->paramsGet);
         }
         if (!empty($query)) {
             $uri->query = http_build_query($query, null, "&");
         }
         $body = $this->_prepareBody();
         $headers = $this->_prepareHeaders();
         // Open the connection, send the request and read the response
         $this->adapter->connect($uri->host, $uri->port, $uri->scheme === "https" ? true : false);
         $this->last_request = $this->adapter->write($this->method, $uri, $this->config["httpversion"], $headers, $body);
         $response = $this->adapter->read();
         if (!$response) {
             $message = __METHOD__ . "() Unable to read response, or response is empty.";
             throw new Sabel_Exception_Runtime($message);
         }
         $response = Sabel_Http_Response::fromString($response);
         if ($this->config["storeresponse"]) {
             $this->last_response = $response;
         }
         // Load cookies into cookie jar
         if (isset($this->cookiejar)) {
             $this->cookiejar->addCookiesFromResponse($response, $uri);
         }
         // If we got redirected, look for the Location header
         if ($response->isRedirect() && ($location = $response->getHeader("location"))) {
             // Check whether we send the exact same request again,
             // or drop the parameters and send a GET request
             if ($response->getStatus() == 303 || !$this->config["strictredirects"] && ($response->getStatus() == 302 || $response->getStatus() == 301)) {
                 $this->resetParameters();
                 $this->setMethod(self::GET);
             }
             // If we got a well formed absolute URI
             $_uri = @parse_url($location);
             if (isset($_uri["scheme"]) && isset($_uri["host"])) {
                 $this->setHeaders("host", null);
                 $this->setUri($location);
             } else {
                 // Split into path and query and set the query
                 if (strpos($location, "?") === false) {
                     $query = "";
                 } else {
                     list($location, $query) = explode("?", $location, 2);
                 }
                 $this->uri->query = $query;
                 // Else, if we got just an absolute path, set it
                 if (strpos($location, "/") === 0) {
                     $this->uri->path = $location;
                 } else {
                     // Get the current path directory, removing any trailing slashes
                     $path = $this->uri->path;
                     $path = rtrim(substr($path, 0, strrpos($path, "/")), "/");
                     $this->uri->path = $path . "/" . $location;
                 }
             }
             ++$this->redirectCounter;
         } else {
             // If we didn't get any location, stop redirecting
             break;
         }
     } while ($this->redirectCounter < $this->config["maxredirects"]);
     return $response;
 }
开发者ID:reoring,项目名称:sabel,代码行数:93,代码来源:Client.php

示例10: request

 /**
  * Send the HTTP request and return an HTTP response object
  *
  * @param string $method
  * @return Zend_Http_Response
  */
 public function request($method = null)
 {
     if (!$this->uri instanceof Zend_Uri_Http) {
         throw new Zend_Http_Client_Exception("No valid URI has been passed to the client");
     }
     if ($method) {
         $this->setMethod($method);
     }
     $this->redirectCounter = 0;
     $response = null;
     // Send the first request. If redirected, continue.
     do {
         // Clone the URI and add the additional GET parameters to it
         $uri = clone $this->uri;
         $uri_params = array();
         parse_str($uri->getQuery(), $uri_params);
         $uri->setQuery(array_merge($uri_params, $this->paramsGet));
         $body = $this->prepare_body();
         $headers = $this->prepare_headers();
         $request = implode("\r\n", $headers) . "\r\n" . $body;
         $this->last_request = $request;
         // Open the connection, send the request and read the response
         $this->adapter->connect($uri->getHost(), $uri->getPort(), $uri->getScheme() == 'https' ? true : false);
         $this->adapter->write($this->method, $uri, $this->config['httpversion'], $headers, $body);
         $response = Zend_Http_Response::factory($this->adapter->read());
         // Load cookies into cookie jar
         if (isset($this->Cookiejar)) {
             $this->Cookiejar->addCookiesFromResponse($response, $uri);
         }
         // If we got redirected, look for the Location header
         if ($response->isRedirect() && ($location = $response->getHeader('location'))) {
             // Check whether we send the exact same request again, or drop the parameters
             // and send a GET request
             if ($response->getStatus() == 303 || !$this->config['strictredirects'] && ($response->getStatus() == 302 || $response->getStatus() == 301)) {
                 $this->resetParameters();
                 $this->setMethod(self::GET);
             }
             // If we got a well formed absolute URI
             if (Zend_Uri_Http::check($location)) {
                 $this->setHeaders('host', null);
                 $this->setUri($location);
             } else {
                 // Split into path and query and set the query
                 list($location, $query) = explode('?', $location, 2);
                 $this->uri->setQueryString($query);
                 // Else, if we got just an absolute path, set it
                 if (strpos($location, '/') === 0) {
                     $this->uri->setPath($location);
                     // Else, assume we have a relative path
                 } else {
                     // Get the current path directory, removing any trailing slashes
                     $path = rtrim(dirname($this->uri->getPath()), "/");
                     $this->uri->setPath($path . '/' . $location);
                 }
             }
             $this->redirectCounter++;
         } else {
             // If we didn't get any location, stop redirecting
             break;
         }
     } while ($this->redirectCounter < $this->config['maxredirects']);
     return $response;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:69,代码来源:Client.php


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