Beispiel #1
0
 /**
  * @param string $url
  * @param string|array $data
  * @return \Kdyby\Curl\Response
  * @throws iDefendCurlException
  */
 public function send($url, $data = '')
 {
     try {
         $request = new Request($this->url . $url);
         $request->setSender($this->curlSender);
         return $request->post(Json::encode($data));
     } catch (CurlException $e) {
         throw new iDefendCurlException($e->getMessage());
     }
 }
Beispiel #2
0
 /**
  * @param array $data
  * @throws CommunicationFailedException
  * @return array
  */
 private function process($data)
 {
     $this->onRequest($data);
     $data = array('USER' => $this->username, 'PWD' => $this->password, 'SIGNATURE' => $this->signature, 'VERSION' => self::API_VERSION) + $data;
     $request = new Curl\Request($this->host, $data);
     $request->setSender($this->curlSender);
     $request->options['verbose'] = TRUE;
     if (strpos($request->getUrl()->getHost(), '.sandbox.') !== FALSE) {
         $request->setCertificationVerify(FALSE);
         $request->options['ssl_verifyHost'] = FALSE;
     }
     try {
         $response = $request->post(http_build_query($data));
         $resultData = self::parseNvp($response->getResponse());
         $this->onSuccess($resultData, $response->getInfo());
         return $resultData;
     } catch (Curl\FailedRequestException $e) {
         $this->onError($e, $e->getInfo());
         throw new CommunicationFailedException($e->getMessage(), 0, $e);
     } catch (Curl\CurlException $e) {
         $this->onError($e, $e->getResponse() ? $e->getResponse()->info : array());
         throw new CommunicationFailedException($e->getMessage(), 0, $e);
     }
 }
Beispiel #3
0
 /**
  * Withdraws btc.
  *
  * @param string $btcAmount
  * @param string $address
  * @return array Withdrawal info
  */
 public function withdrawBtc($btcAmount, $address)
 {
     $nonce = $this->getNonce();
     $params = array('key' => $this->apiKey, 'nonce' => $nonce, 'signature' => $this->getSignature($nonce), 'amount' => $btcAmount, 'address' => $address);
     $request = new Request(static::BTC_WITHDRAWAL_URL);
     $request->setTrustedCertificate(CertificateHelper::getCaInfoFile());
     $response = $request->post($params);
     return json_decode($response->getResponse(), TRUE);
 }