本文整理汇总了PHP中Varien_Http_Client::getUri方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Http_Client::getUri方法的具体用法?PHP Varien_Http_Client::getUri怎么用?PHP Varien_Http_Client::getUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Http_Client
的用法示例。
在下文中一共展示了Varien_Http_Client::getUri方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _postRequest
/**
* Send request to gateway
*
* @param Mage_Chronopay_Model_Gateway_Request
* @return mixed
*/
protected function _postRequest(Mage_Chronopay_Model_Gateway_Request $request)
{
$result = AO::getModel('chronopay/gateway_result');
$client = new Varien_Http_Client();
$url = $this->getConfigData('cgi_url');
$client->setUri($url ? $url : self::CGI_URL);
$client->setConfig(array('maxredirects' => 0, 'timeout' => 30));
$client->setParameterPost($request->getData());
$client->setMethod(Zend_Http_Client::POST);
if ($this->getConfigData('debug_flag')) {
$debug = AO::getModel('chronopay/api_debug')->setRequestBody($client->getUri() . "\n" . print_r($request->getData(), 1))->save();
}
try {
$response = $client->request();
$body = $response->getRawBody();
if (preg_match('/(T\\|(.+)\\|[\\r\\n]{0,}){0,1}(Y\\|(.+)?|\\|)|(N\\|(.+[\\r\\n]{0,}.+){0,})/', $body, $matches)) {
$transactionId = $matches[2];
$message = isset($matches[4]) ? trim($matches[4], '|') : '';
if (isset($matches[5], $matches[6])) {
$result->setError($matches[6]);
AO::throwException($matches[6]);
}
if ($message == 'Completed') {
$result->setTransaction($request->getTransaction());
}
if (strlen($transactionId)) {
$result->setTransaction($transactionId);
}
if (!$result->getTransaction()) {
AO::throwException(AO::helper('chronopay')->__('Transaction ID is invalid'));
}
} else {
AO::throwException(AO::helper('chronopay')->__('Invalid response format'));
}
if ($this->getConfigData('debug_flag')) {
$debug->setResponseBody($body)->save();
}
} catch (Exception $e) {
$result->setResponseCode(-1)->setResponseReasonCode($e->getCode())->setResponseReasonText($e->getMessage());
$exceptionMsg = AO::helper('chronopay')->__('Gateway request error: %s', $e->getMessage());
if ($this->getConfigData('debug_flag')) {
$debug->setResponseBody($body)->save();
}
AO::throwException($exceptionMsg);
}
return $result;
}