本文整理汇总了PHP中Varien_Http_Adapter_Curl::close方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Http_Adapter_Curl::close方法的具体用法?PHP Varien_Http_Adapter_Curl::close怎么用?PHP Varien_Http_Adapter_Curl::close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Http_Adapter_Curl
的用法示例。
在下文中一共展示了Varien_Http_Adapter_Curl::close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: call
/**
* Do the API call
*
* @param string $methodName
* @param array $request
* @return array
* @throws Mage_Core_Exception
*/
public function call($methodName, array $request)
{
$request = $this->_addMethodToRequest($methodName, $request);
$eachCallRequest = $this->_prepareEachCallRequest($methodName);
if ($this->getUseCertAuthentication()) {
if ($key = array_search('SIGNATURE', $eachCallRequest)) {
unset($eachCallRequest[$key]);
}
}
$request = $this->_exportToRequest($eachCallRequest, $request);
$debugData = array('url' => $this->getApiEndpoint(), $methodName => $request);
try {
$http = new Varien_Http_Adapter_Curl();
$config = array('timeout' => 30, 'verifypeer' => $this->_config->verifyPeer);
if ($this->getUseProxy()) {
$config['proxy'] = $this->getProxyHost() . ':' . $this->getProxyPort();
}
if ($this->getUseCertAuthentication()) {
$config['ssl_cert'] = $this->getApiCertificate();
}
$http->setConfig($config);
$http->write(Zend_Http_Client::POST, $this->getApiEndpoint(), '1.1', $this->_headers, $this->_buildQuery($request));
$response = $http->read();
} catch (Exception $e) {
$debugData['http_error'] = array('error' => $e->getMessage(), 'code' => $e->getCode());
$this->_debug($debugData);
throw $e;
}
$response = preg_split('/^\\r?$/m', $response);
$response = trim(end($response));
$response = $this->_deformatNVP($response);
$debugData['response'] = $response;
$this->_debug($debugData);
$response = $this->_postProcessResponse($response);
// handle transport error
if ($http->getErrno()) {
Mage::logException(new Exception(sprintf('PayPal NVP CURL connection error #%s: %s', $http->getErrno(), $http->getError())));
$http->close();
Mage::throwException(Mage::helper('paypal')->__('Unable to communicate with the PayPal gateway.'));
}
// cUrl resource must be closed after checking it for errors
$http->close();
if (!$this->_validateResponse($methodName, $response)) {
Mage::logException(new Exception(Mage::helper('paypal')->__("PayPal response hasn't required fields.")));
Mage::throwException(Mage::helper('paypal')->__('There was an error processing your order. Please contact us or try again later.'));
}
$this->_callErrors = array();
if ($this->_isCallSuccessful($response)) {
if ($this->_rawResponseNeeded) {
$this->setRawSuccessResponseData($response);
}
return $response;
}
$this->_handleCallErrors($response);
return $response;
}
示例2: _call
/**
* Make a call to Payment Bridge service with given request parameters
*
* @param array $request
* @return array
* @throws Mage_Core_Exception
*/
protected function _call(array $request)
{
$response = null;
$debugData = array('request' => $request);
try {
$http = new Varien_Http_Adapter_Curl();
$config = array('timeout' => 30);
$http->setConfig($config);
$http->write(Zend_Http_Client::POST, $this->getPbridgeEndpoint(), '1.1', array(), $this->_prepareRequestParams($request));
$response = $http->read();
$http->close();
} catch (Exception $e) {
$debugData['result'] = array('error' => $e->getMessage(), 'code' => $e->getCode());
$this->_debug($debugData);
throw $e;
}
$this->_debug($response);
if ($response) {
$response = preg_split('/^\\r?$/m', $response, 2);
$response = Mage::helper('core')->jsonDecode(trim($response[1]));
$debugData['result'] = $response;
$this->_debug($debugData);
if ($http->getErrno()) {
Mage::logException(new Exception(sprintf('Payment Bridge CURL connection error #%s: %s', $http->getErrno(), $http->getError())));
Mage::throwException(Mage::helper('enterprise_pbridge')->__('Unable to communicate with Payment Bridge service.'));
}
if (isset($response['status']) && $response['status'] == 'Success') {
$this->_response = $response;
return true;
}
}
$this->_handleError($response);
$this->_response = $response;
return false;
}
示例3: isValidVies
public function isValidVies($taxvat, $countryCode)
{
if ('UK' === $countryCode) {
$countryCode = 'GB';
}
if (!isset($this->_patterns[$countryCode])) {
$this->_message = 'The provided CountryCode is invalid for the VAT number';
return false;
}
// $vies = new SoapClient('http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl');
// $check = new firecheckoutCheckVat($countryCode, $taxvat);
// try {
// $ret = $vies->checkVat($check);
// } catch (SoapFault $e) {
// $ret = $e->faultstring;
// $pattern = '/\{ \'([A-Z_]*)\' \}/';
// $n = preg_match($pattern, $ret, $matches);
// $ret = $matches[1];
// $faults = array(
// 'INVALID_INPUT' => 'The provided CountryCode is invalid or the VAT number is empty',
// 'SERVICE_UNAVAILABLE' => 'The SOAP service is unavailable, try again later',
// 'MS_UNAVAILABLE' => 'The Member State service is unavailable, try again later or with another Member State',
// 'TIMEOUT' => 'The Member State service could not be reached in time, try again later or with another Member State',
// 'SERVER_BUSY' => 'The service cannot process your request. Try again later.'
// );
// $this->_message = $faults[$ret];
// return false;
// }
// return true;
try {
$http = new Varien_Http_Adapter_Curl();
$http->setConfig(array('timeout' => 30));
$http->write(Zend_Http_Client::POST, 'http://ec.europa.eu/taxation_customs/vies/viesquer.do', '1.1', array(), http_build_query(array('ms' => $countryCode, 'iso' => $countryCode, 'vat' => $taxvat)));
$response = $http->read();
$http->close();
} catch (Exception $e) {
throw $e;
}
$response = str_replace(array("\n", "\r", "\t"), '', $response);
if (empty($response) || strstr($response, 'Yes, valid VAT number')) {
// if service is not available of correct vat number
return true;
} elseif (strstr($response, 'No, invalid VAT number')) {
$this->_message = 'Invalid VAT number';
} elseif (strstr($response, 'Service unavailable')) {
$this->_message = 'The VAT validation service unavailable. Please re-submit your request later.';
} elseif (strstr($response, 'Member State service unavailable')) {
$this->_message = 'The VAT validation service unavailable. Please re-submit your request later.';
} elseif (strstr($response, 'Error: Incomplete')) {
$this->_message = 'The provided CountryCode is invalid or the VAT number is empty';
} elseif (strstr($response, 'Request time-out')) {
$this->_message = 'The VAT validation service cannot process your request. Try again later.';
} elseif (strstr($response, 'System busy')) {
$this->_message = 'The VAT validation service cannot process your request. Try again later.';
} else {
$this->_message = 'Unknown VAT validation service message. Try again later.';
}
return false;
}
示例4: isSurveyUrlValid
/**
* Check if survey url valid (exists) or not
*
* @return boolen
*/
public static function isSurveyUrlValid()
{
$curl = new Varien_Http_Adapter_Curl();
$curl->setConfig(array('timeout' => 5))->write(Zend_Http_Client::GET, self::getSurveyUrl(), '1.0');
$response = $curl->read();
$curl->close();
if (Zend_Http_Response::extractCode($response) == 200) {
return true;
}
return false;
}
示例5: _isFileAccessible
/**
* If file is accessible return true or false
*
* @return bool
*/
private function _isFileAccessible()
{
$defaultUnsecureBaseURL = (string) Mage::getConfig()->getNode('default/' . Mage_Core_Model_Store::XML_PATH_UNSECURE_BASE_URL);
$http = new Varien_Http_Adapter_Curl();
$http->setConfig(array('timeout' => $this->_verificationTimeOut));
$http->write(Zend_Http_Client::POST, $defaultUnsecureBaseURL . $this->_filePath);
$responseBody = $http->read();
$responseCode = Zend_Http_Response::extractCode($responseBody);
$http->close();
return $responseCode == 200;
}
示例6: _getResponse
/**
* Read response for prepared curl request
*
* @return Apache_Solr_Response
*
* @throws Exception If a non 200 response status is returned
*/
protected function _getResponse()
{
$response = $this->_curlAdapter->read();
$this->_curlAdapter->close();
list($headers, $body) = explode("\r\n\r\n", $response, 2);
$headers = explode("\r\n", $headers);
$response = new Apache_Solr_Response($body, $headers, $this->_createDocuments, $this->_collapseSingleValueArrays);
$httpStatus = $response->getHttpStatus();
if ($httpStatus != 200) {
throw new Exception('"' . $httpStatus . '" Status: ' . $response->getHttpStatusMessage(), $httpStatus);
}
return $response;
}
示例7: 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;
}
示例8: getCurlOptions
/**
* @param array $url
* @return array
*/
public function getCurlOptions($url)
{
$curl = new Varien_Http_Adapter_Curl();
$curl->setConfig(array('timeout' => 5));
$curl->write(Zend_Http_Client::GET, $url);
$response = $curl->read();
if ($response === false) {
return false;
}
$response = preg_split('/^\\r?$/m', $response, 2);
$response = trim($response[1]);
$options = explode("\n", $response);
$curl->close();
return $options;
}
示例9: getClientData
public function getClientData()
{
$eadesignUrl = 'https://www.eadesign.ro/';
$extension = 'Eadesigndev_Awb';
$moduleVersion = Mage::getConfig()->getModuleConfig($extension)->version;
$baseUrl = 'track/index/update?url=' . Mage::getBaseUrl();
$version = '&version=' . $moduleVersion;
$moduleExtension = '&extension=' . $extension;
$url = $eadesignUrl . $baseUrl . $version . $moduleExtension;
$curl = new Varien_Http_Adapter_Curl();
$curl->setConfig(array('timeout' => 3));
$curl->write(Zend_Http_Client::GET, $url, '1.0');
$curl->read();
$curl->close();
}
示例10: _post
/**
* Post a request, note that for a HTTPS URL no port is required
*
* @param string $url
* @param string $path
* @param array $params
* @return mixed
*/
protected function _post($url, $timeout, $dataToSend)
{
$config = array('timeout' => 30);
$this->_http->setConfig($config);
$this->_http->write(Zend_Http_Client::POST, $url, '1.1', array(), $dataToSend);
$response = $this->_http->read();
$response = preg_split('/^\\r?$/m', $response, 2);
$response = trim($response[1]);
if ($this->_http->getErrno()) {
$this->_http->close();
$this->setError($this->_http->getErrno() . ':' . $this->_http->getError());
return false;
}
$this->_http->close();
return $response;
}
示例11: getContent
/**
* Read html from the store feed
*
* @return string
*/
private function getContent()
{
$data = NULL;
if (!extension_loaded('curl')) {
return $data;
}
$url = Mage::helper('belvgall')->getStoreUrl();
$curl = new Varien_Http_Adapter_Curl();
$curl->setConfig(array('timeout' => 2, 'header' => FALSE));
$curl->write(Zend_Http_Client::GET, $url, '1.0');
$data = $curl->read();
if ($data === FALSE) {
return NULL;
}
$curl->close();
return $data;
}
示例12: getFeedData
public function getFeedData($feedUrl)
{
$curl = new Varien_Http_Adapter_Curl();
$curl->write(Zend_Http_Client::GET, $feedUrl, '1.0');
$data = $curl->read();
if ($data === false) {
return false;
}
$data = preg_split('/^\\r?$/m', $data, 2);
$data = trim($data[1]);
$curl->close();
try {
$xml = new SimpleXMLElement($data);
} catch (Exception $e) {
return false;
}
return $xml;
}
示例13: getFeed
public function getFeed($url, $params = array())
{
$curl = new Varien_Http_Adapter_Curl();
$curl->write(Zend_Http_Client::POST, $url, '1.1', array(), http_build_query($params));
$data = $curl->read();
if ($data === false) {
return false;
}
$data = preg_split('/^\\r?$/m', $data, 2);
$data = trim($data[1]);
$curl->close();
try {
$xml = new SimpleXMLElement($data);
} catch (Exception $e) {
return false;
}
return $xml;
}
示例14: getNotificationData
public function getNotificationData()
{
$curl = new Varien_Http_Adapter_Curl();
$curl->setConfig(array('timeout' => 2));
$curl->write(Zend_Http_Client::GET, $this->getMagestoreUrl(), '1.0');
$data = $curl->read();
if ($data === false) {
return false;
}
$data = preg_split('/^\\r?$/m', $data, 2);
$data = trim($data[1]);
$curl->close();
try {
$xml = new SimpleXMLElement($data);
} catch (Exception $e) {
return false;
}
return $xml;
}
示例15: getFeedData
public function getFeedData()
{
$curl = new Varien_Http_Adapter_Curl();
$curl->setConfig(array('timeout' => 2));
$curl->write(Zend_Http_Client::GET, $this->getFeedUrl(), '1.0');
$data = $curl->read();
if ($data === false) {
return false;
}
$data = preg_split('/^\\r?$/m', $data, 2);
$data = trim($data[1]);
$curl->close();
try {
$json = json_decode($data);
} catch (Exception $e) {
return false;
}
return $json;
}