Esempio n. 1
0
 /**
  * license the app
  * 
  */
 public static function license($activationKey, $productToken)
 {
     $url = 'https://ls.amazonaws.com/';
     $client = new Varien_Http_Client($url);
     $client->setMethod(Zend_Http_Client::GET);
     $client->setParameterGet("Action", "ActivateDesktopProduct");
     $client->setParameterGet("ActivationKey", $activationKey);
     $client->setParameterGet("ProductToken", $productToken);
     $response = $client->request();
     if ($response->isSuccessful()) {
         $body = $response->getRawBody();
         $xml = new SimpleXMLElement($body);
         $result = array();
         $result["access"] = $xml->ActivateDesktopProductResult->AWSAccessKeyId;
         $result["secret"] = $xml->ActivateDesktopProductResult->SecretAccessKey;
         $result["usertoken"] = $xml->ActivateDesktopProductResult->UserToken;
         // uncomment to debug raw submission response
         //Mage::log("result=" . print_r($result,true));
         return $result;
     } else {
         Mage::log("Activation failed to URL: " . $url . ", HTTP response code was not 200");
         Mage::log("Raw response: " . print_r($response, true));
         return false;
     }
 }
Esempio n. 2
0
 /**
  * Send the HTTP request and return an HTTP response object
  *
  * @param string $url
  * @param Varien_Object $data
  * @param string $method
  * @return Varien_Object
  */
 public function request($url, Varien_Object $data, $method = 'GET')
 {
     $client = new Varien_Http_Client($url, array('timeout' => 30));
     $client->setMethod($method);
     if ($method == Zend_Http_Client::POST) {
         $client->setParameterPost($this->_parseArray($data));
     } else {
         $client->setParameterGet($this->_parseArray($data));
     }
     $response = $client->request();
     $body = json_decode($response->getBody(), true);
     $result = $this->_parseObject($body);
     return $result;
 }
Esempio n. 3
0
 protected function _postRequest($request)
 {
     $client = new Varien_Http_Client();
     $client->setUri($this->getUrl());
     $client->setConfig(array('maxredirects' => 2, 'timeout' => 60));
     $client->setParameterGet($request);
     $client->setMethod(Zend_Http_Client::GET);
     try {
         $response = $client->request();
     } catch (Exception $e) {
         Mage::throwException(Mage::helper('pnsofortueberweisung')->__('Gateway request error: %s', $e->getMessage()));
     }
     $responseBody = $response->getBody();
     return $responseBody;
 }