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


PHP Varien_Http_Client::setAuth方法代码示例

本文整理汇总了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;
     }
 }
开发者ID:ArjenMiedema,项目名称:magento-sign2pay,代码行数:29,代码来源:Processor.php

示例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 '';
 }
开发者ID:CE-Webmaster,项目名称:CE-Hub,代码行数:26,代码来源:Data.php


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