本文整理匯總了PHP中Varien_Http_Client::setUrlEncodeBody方法的典型用法代碼示例。如果您正苦於以下問題:PHP Varien_Http_Client::setUrlEncodeBody方法的具體用法?PHP Varien_Http_Client::setUrlEncodeBody怎麽用?PHP Varien_Http_Client::setUrlEncodeBody使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Varien_Http_Client
的用法示例。
在下文中一共展示了Varien_Http_Client::setUrlEncodeBody方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _postRequest
protected function _postRequest(Varien_Object $request)
{
if ($this->getConfigData('debug')) {
foreach ($request->getData() as $key => $value) {
$value = (string) $value;
$requestData[] = strtoupper($key) . '[' . strlen($value) . ']=' . $value;
}
$requestData = join('&', $requestData);
$debug = Mage::getModel('paygate/authorizenet_debug')->setRequestBody($requestData)->setRequestSerialized(serialize($request->getData()))->setRequestDump(print_r($request->getData(), 1))->save();
}
$client = new Varien_Http_Client();
$_config = array('maxredirects' => 5, 'timeout' => 30);
$_isProxy = $this->getConfigData('use_proxy', false);
if ($_isProxy) {
$_config['proxy'] = $this->getConfigData('proxy_host') . ':' . $this->getConfigData('proxy_port');
//http://proxy.shr.secureserver.net:3128',
$_config['httpproxytunnel'] = true;
$_config['proxytype'] = CURLPROXY_HTTP;
}
$uri = $this->getConfigData('url');
$client->setUri($uri)->setConfig($_config)->setMethod(Zend_Http_Client::POST)->setParameterPost($request->getData())->setHeaders('X-VPS-VIT-CLIENT-CERTIFICATION-ID: 33baf5893fc2123d8b191d2d011b7fdc')->setHeaders('X-VPS-Request-ID: ' . $request->getRequestId())->setHeaders('X-VPS-CLIENT-TIMEOUT: ' . $this->_clientTimeout);
/*
* we are sending request to payflow pro without url encoding
* so we set up _urlEncodeBody flag to false
*/
$response = $client->setUrlEncodeBody(false)->request();
$result = Mage::getModel('paygate/payflow_pro_result');
$response = strstr($response->getBody(), 'RESULT');
$valArray = explode('&', $response);
foreach ($valArray as $val) {
$valArray2 = explode('=', $val);
$result->setData(strtolower($valArray2[0]), $valArray2[1]);
}
$result->setResultCode($result->getResult())->setRespmsg($result->getRespmsg());
if (!empty($debug)) {
$debug->setResponseBody($response)->setResultSerialized(serialize($result->getData()))->setResultDump(print_r($result->getData(), 1))->save();
}
return $result;
}
示例2: _postRequest
/**
* Post request to gateway and return response
*
* @param Varien_Object $request
* @return Varien_Object
*/
protected function _postRequest(Varien_Object $request)
{
$debugData = array('request' => $request->getData());
$client = new Varien_Http_Client();
$result = new Varien_Object();
$_config = array('maxredirects' => 5, 'timeout' => 30);
$_isProxy = $this->getConfigData('use_proxy', false);
if ($_isProxy) {
$_config['proxy'] = $this->getConfigData('proxy_host') . ':' . $this->getConfigData('proxy_port');
//http://proxy.shr.secureserver.net:3128',
$_config['httpproxytunnel'] = true;
$_config['proxytype'] = CURLPROXY_HTTP;
}
$client->setUri($this->_getTransactionUrl())->setConfig($_config)->setMethod(Zend_Http_Client::POST)->setParameterPost($request->getData())->setHeaders('X-VPS-VIT-CLIENT-CERTIFICATION-ID: 33baf5893fc2123d8b191d2d011b7fdc')->setHeaders('X-VPS-Request-ID: ' . $request->getRequestId())->setHeaders('X-VPS-CLIENT-TIMEOUT: ' . $this->_clientTimeout);
try {
/**
* we are sending request to payflow pro without url encoding
* so we set up _urlEncodeBody flag to false
*/
$response = $client->setUrlEncodeBody(false)->request();
} catch (Exception $e) {
$result->setResponseCode(-1)->setResponseReasonCode($e->getCode())->setResponseReasonText($e->getMessage());
$debugData['result'] = $result->getData();
$this->_debug($debugData);
throw $e;
}
$response = strstr($response->getBody(), 'RESULT');
$valArray = explode('&', $response);
foreach ($valArray as $val) {
$valArray2 = explode('=', $val);
$result->setData(strtolower($valArray2[0]), $valArray2[1]);
}
$result->setResultCode($result->getResult())->setRespmsg($result->getRespmsg());
$debugData['result'] = $result->getData();
$this->_debug($debugData);
return $result;
}
示例3: _tokenWorker
private function _tokenWorker($token, $request)
{
$base64ClientID = base64_encode($this->_clientId . ":" . $this->_clientSecret);
$client = new Varien_Http_Client();
$result = new Varien_Object();
$_config = array('maxredirects' => 5, 'timeout' => 5);
$client->setUri($this->getAccessTokenEndPoint())->setConfig($_config)->setMethod(Zend_Http_Client::POST)->setParameterPost($request->getData())->setHeaders('User-Agent: Varien_Http_Client')->setHeaders('Authorization: Basic ' . $base64ClientID)->setHeaders('Accept: */*');
try {
$response = $client->setUrlEncodeBody(false)->request();
} catch (Exception $e) {
$result->setResponseCode(-1)->setResponseReasonCode($e->getCode())->setResponseReasonText($e->getMessage());
$debugData['result'] = $result->getData();
$this->_debug($debugData);
throw new Mage_Exception($e->getMessage());
return false;
}
$body = Mage::helper('core')->jsonDecode($response->getBody());
$result->addData($body);
$debugData['result'] = $result->getData();
$this->_debug($debugData);
if (isset($debugData['result']['error'])) {
Mage::log($debugData['result']['error_description']);
return false;
}
return $result;
}