From 884561b8d8c91b01f7db25284c2be9923c809412 Mon Sep 17 00:00:00 2001 From: bgsrb Date: Tue, 26 Feb 2019 16:19:19 +0330 Subject: [PATCH] add insecure option --- src/KavenegarApi.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/KavenegarApi.php b/src/KavenegarApi.php index 24d8fe7..ff0e946 100644 --- a/src/KavenegarApi.php +++ b/src/KavenegarApi.php @@ -10,10 +10,9 @@ class KavenegarApi { - protected $apiKey; - const APIPATH = "https://api.kavenegar.com/v1/%s/%s/%s.json/"; - const VERSION = "1.1.0"; - public function __construct($apiKey) + const APIPATH = "%s://api.kavenegar.com/v1/%s/%s/%s.json/"; + const VERSION = "1.2.2"; + public function __construct($apiKey,$insecure=false) { if (!extension_loaded('curl')) { die('cURL library is not loaded'); @@ -23,12 +22,13 @@ public function __construct($apiKey) die('apiKey is empty'); exit; } - $this->apiKey = $apiKey; + $this->apiKey = trim($apiKey); + $this->insecure = $insecure; } protected function get_path($method, $base = 'sms') { - return sprintf(self::APIPATH, $this->apiKey, $base, $method); + return sprintf(self::APIPATH,$this->insecure==true ? "http": "https", $this->apiKey, $base, $method); } protected function execute($url, $data = null)