Skip to content

Commit

Permalink
add insecure option
Browse files Browse the repository at this point in the history
  • Loading branch information
bgsrb committed Feb 26, 2019
1 parent 02dac39 commit 884561b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/KavenegarApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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)
Expand Down

0 comments on commit 884561b

Please sign in to comment.