本文整理汇总了PHP中Varien_Http_Client::setAuth方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Http_Client::setAuth方法的具体用法?PHP Varien_Http_Client::setAuth怎么用?PHP Varien_Http_Client::setAuth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Http_Client
的用法示例。
在下文中一共展示了Varien_Http_Client::setAuth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _verifyResponse
/**
* Veritfy the gateway response
*
* @param string $apiKey
* @param string $token
* @param string $timestamp
* @param string $signature
* @return boolean
*/
public function _verifyResponse($purchase_id)
{
$client_id = Mage::helper('sign2pay')->getSign2payClientId();
$client_secret = Mage::helper('sign2pay')->getSign2payClientSecret();
$client = new Varien_Http_Client('https://app.sign2pay.com/api/v2/payment/status/' . $purchase_id);
$client->setMethod(Varien_Http_Client::GET);
$client->setAuth($client_id, $client_secret);
try {
$response = $client->request();
$body = json_decode($response->getBody());
if (array_key_exists('status', $body) || $body['status'] == 'processing') {
return true;
} else {
return false;
}
} catch (Zend_Http_Client_Exception $e) {
Mage::logException($e);
return false;
}
}
示例2: request
public function request($url, $params, $object = null, $timeout = null)
{
if (!$timeout) {
$timeout = 0;
}
try {
$client = new Varien_Http_Client();
$client->setUri($url)->setConfig(array('timeout' => $timeout))->setHeaders('accept-encoding', '')->setParameterPost($params)->setMethod(Zend_Http_Client::POST);
if ($object instanceof Mageplace_Backup_Model_Backup && $object->getProfileData(Mageplace_Backup_Model_Profile::COLUMN_AUTH_ENABLE) && $object->getProfileData(Mageplace_Backup_Model_Profile::COLUMN_AUTH_USER)) {
$client->setAuth($object->getProfileData(Mageplace_Backup_Model_Profile::COLUMN_AUTH_USER), $object->getProfileData(Mageplace_Backup_Model_Profile::COLUMN_AUTH_PASSWORD));
} elseif ($object instanceof Mageplace_Backup_Model_Profile && $object->getData(Mageplace_Backup_Model_Profile::COLUMN_AUTH_ENABLE) && $object->getData(Mageplace_Backup_Model_Profile::COLUMN_AUTH_USER)) {
$client->setAuth($object->getData(Mageplace_Backup_Model_Profile::COLUMN_AUTH_USER), $object->getData(Mageplace_Backup_Model_Profile::COLUMN_AUTH_PASSWORD));
}
$response = $client->request();
return $response->getRawBody();
} catch (Zend_Http_Client_Exception $zhce) {
if ($zhce->getMessage() != 'Unable to read response, or response is empty') {
Mage::logException($zhce);
throw $zhce;
}
} catch (Exception $e) {
Mage::logException($e);
throw $e;
}
return '';
}