From edb2d0d4678db971889f46620d95901afd3ff49a Mon Sep 17 00:00:00 2001 From: Vladislavs Dovoreckis <36668842+vlad-evg@users.noreply.github.com> Date: Thu, 30 Apr 2020 18:47:16 +0300 Subject: [PATCH] Add files via upload --- GoGetSSLApi.php | 60 ++++++++++++++----------------------------------- 1 file changed, 17 insertions(+), 43 deletions(-) diff --git a/GoGetSSLApi.php b/GoGetSSLApi.php index 97025c3..f701f13 100644 --- a/GoGetSSLApi.php +++ b/GoGetSSLApi.php @@ -1,18 +1,5 @@ key = isset($key) ? $key : null; + public function __construct($key = null) { + $this->key = $key != null ? $key : null; } public function auth($user, $pass) { @@ -139,8 +126,8 @@ class GoGetSSLApi { return $this->call('/tools/webservers/' . (int) $type, $getData); } - - public function getDomainAlternative($csr = null) { + + public function getDomainAlternative($csr) { if (!$this->key) { throw new GoGetSSLAuthException (); } else { @@ -149,7 +136,9 @@ class GoGetSSLApi { ); } - $postData ['csr'] = $csr; + if ($csr) { + $postData ['csr'] = trim($csr); + } return $this->call('/tools/domain/alternative/', $getData, $postData); } @@ -223,7 +212,7 @@ class GoGetSSLApi { return $this->call('/products/', $getData); } - + public function getProduct($productId) { if (!$this->key) { throw new GoGetSSLAuthException (); @@ -235,7 +224,7 @@ class GoGetSSLApi { return $this->call('/products/ssl/' . $productId, $getData); } - + public function getProducts() { if (!$this->key) { throw new GoGetSSLAuthException (); @@ -379,7 +368,7 @@ class GoGetSSLApi { return $this->call('/orders/add_ssl_order1/', $getData, $data); } - + public function addSSLOrder($data) { if (!$this->key) { throw new GoGetSSLAuthException (); @@ -427,7 +416,7 @@ class GoGetSSLApi { return $this->call('/orders/ssl/activate/' . (int) $orderId, $getData); } - + public function addSandboxAccount($data) { if (!$this->key) { throw new GoGetSSLAuthException (); @@ -437,7 +426,7 @@ class GoGetSSLApi { ); } - return $this->call('/accounts/sandbox/add/', $getData, $data); + return $this->call('/accounts/sandbox/add/', $getData, $data); } public function getOrderStatus($orderId) { @@ -535,7 +524,7 @@ class GoGetSSLApi { return $this->call('/tools/csr/generate/', $getData, $data); } - protected function call($uri, $getData = array(), $postData = array(), $forcePost = false, $isFile = false) { + protected function call($uri, $getData = array(), $postData = array(), $forcePost = false, $isFile = false) { $url = $this->apiUrl . $uri; if (!empty($getData)) { foreach ($getData as $key => $value) { @@ -560,26 +549,12 @@ class GoGetSSLApi { $result = curl_exec($c); - if (DEBUG == 'TRUE') { - echo "\n\n"; - echo "===============\n"; - echo __FILE__ . "\n"; - echo "===============\n\n"; - echo "url = " . $url . "\n\n"; - echo "queryData = " . urldecode($queryData) . "\n\n"; - echo "getData = \n"; - print_r($getData) . "\n\n"; - echo "postData = \n"; - print_r($postData) . "\n\n"; - echo "result GoGetSslApi = \n"; - print_r(json_decode($result, true)); - echo "\n\n"; - } - $status = curl_getinfo($c, CURLINFO_HTTP_CODE); - curl_close($c); + curl_close($c); + $this->lastStatus = $status; - $this->lastResponse = json_decode($result, true); + $this->lastResponse = json_decode($result, true); + return $this->lastResponse; } @@ -598,5 +573,4 @@ class GoGetSSLAuthException extends Exception { public function __construct() { parent::__construct('Please authorize first'); } - }