From c6024b0271ecca3d392f84a63b2395ec72039cee Mon Sep 17 00:00:00 2001 From: saeed sajadi Date: Sat, 5 Jan 2019 11:52:31 +0330 Subject: [PATCH 01/11] make optional VerifyLookup function parameters --- src/KavenegarApi.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/KavenegarApi.php b/src/KavenegarApi.php index 24d8fe7..dc662dc 100644 --- a/src/KavenegarApi.php +++ b/src/KavenegarApi.php @@ -258,7 +258,7 @@ public function AccountConfig($apilogs, $dailyreport, $debug, $defaultsender, $m return $this->execute($path, $params); } - public function VerifyLookup($receptor, $token, $token2, $token3, $template, $type = null) + public function VerifyLookup($receptor, $token, $token2 = null, $token3 = null, $template = 'verify', $type = null) { $path = $this->get_path("lookup", "verify"); $params = array( @@ -291,4 +291,4 @@ public function CallMakeTTS($receptor, $message, $date = null, $localid = null) return $this->execute($path, $params); } } -?> \ No newline at end of file +?> From b5f06f2a1224b1e901e74379ce97a71c20d312c0 Mon Sep 17 00:00:00 2001 From: nimasdj Date: Sun, 20 Oct 2019 22:07:07 +0330 Subject: [PATCH 02/11] Update KavenegarApi.php --- src/KavenegarApi.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/KavenegarApi.php b/src/KavenegarApi.php index ff0e946..8042642 100644 --- a/src/KavenegarApi.php +++ b/src/KavenegarApi.php @@ -67,7 +67,7 @@ protected function execute($url, $data = null) if ($json_return->status != 200) { throw new ApiException($json_return->message, $json_return->status); } - return $json_response->entries; + return $response; } } @@ -291,4 +291,4 @@ public function CallMakeTTS($receptor, $message, $date = null, $localid = null) return $this->execute($path, $params); } } -?> \ No newline at end of file +?> From 26eb00b163b26ba1cac9d0abe10cd2210e59773d Mon Sep 17 00:00:00 2001 From: nimasdj Date: Mon, 21 Oct 2019 07:20:52 +0330 Subject: [PATCH 03/11] Update KavenegarApi.php Better to remove closing tag. --- src/KavenegarApi.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/KavenegarApi.php b/src/KavenegarApi.php index 8042642..94f93d7 100644 --- a/src/KavenegarApi.php +++ b/src/KavenegarApi.php @@ -291,4 +291,3 @@ public function CallMakeTTS($receptor, $message, $date = null, $localid = null) return $this->execute($path, $params); } } -?> From da60a96293de291d23855bc3927955cbfd775608 Mon Sep 17 00:00:00 2001 From: nimasdj Date: Sat, 2 Nov 2019 19:43:43 +0330 Subject: [PATCH 04/11] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a123abd..cc32c77 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,10 @@ # kavenegar-PHP [![Latest Stable Version](https://poser.pugx.org/kavenegar/php/v/stable.svg)](https://packagist.org/packages/kavenegar/php) [![Total Downloads](https://poser.pugx.org/kavenegar/php/downloads.svg)](https://packagist.org/packages/kavenegar/php) - + +[![Latest Stable Version](https://img.shields.io/github/v/release/phplicengine/bitly)](https://packagist.org/packages/kavenegar/php) + + # Kavenegar RESTful API Document If you need to future information about API document Please visit RESTful Document From 8ef1dd780aec2be7a4b159cb75db1298cf189e42 Mon Sep 17 00:00:00 2001 From: nimasdj Date: Sat, 2 Nov 2019 20:06:28 +0330 Subject: [PATCH 05/11] Update README.md --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index cc32c77..ba25d84 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,6 @@ [![Latest Stable Version](https://poser.pugx.org/kavenegar/php/v/stable.svg)](https://packagist.org/packages/kavenegar/php) [![Total Downloads](https://poser.pugx.org/kavenegar/php/downloads.svg)](https://packagist.org/packages/kavenegar/php) -[![Latest Stable Version](https://img.shields.io/github/v/release/phplicengine/bitly)](https://packagist.org/packages/kavenegar/php) - - # Kavenegar RESTful API Document If you need to future information about API document Please visit RESTful Document From a3ec742b02439e2fcd9ffea742df0776852b5656 Mon Sep 17 00:00:00 2001 From: Masoud Tavakkoli Date: Tue, 31 Mar 2020 17:26:51 +0430 Subject: [PATCH 06/11] add token10 and token20 --- src/KavenegarApi.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/KavenegarApi.php b/src/KavenegarApi.php index ff0e946..8a3e7ec 100644 --- a/src/KavenegarApi.php +++ b/src/KavenegarApi.php @@ -258,7 +258,7 @@ public function AccountConfig($apilogs, $dailyreport, $debug, $defaultsender, $m return $this->execute($path, $params); } - public function VerifyLookup($receptor, $token, $token2, $token3, $template, $type = null) + public function VerifyLookup($receptor, $token, $token2, $token3, $template, $token10= null, $token20 = null, $type = null) { $path = $this->get_path("lookup", "verify"); $params = array( @@ -266,6 +266,8 @@ public function VerifyLookup($receptor, $token, $token2, $token3, $template, $ty "token" => $token, "token2" => $token2, "token3" => $token3, + "token10" => $token10, + "token20" => $token20, "template" => $template, "type" => $type ); @@ -291,4 +293,4 @@ public function CallMakeTTS($receptor, $message, $date = null, $localid = null) return $this->execute($path, $params); } } -?> \ No newline at end of file +?> From 853b1f647dcae613e803b003399473969a20223c Mon Sep 17 00:00:00 2001 From: Shahin Sorkh Date: Wed, 17 Aug 2022 06:08:24 +0000 Subject: [PATCH 07/11] throw excpetion instead of terminating whole process --- src/Exceptions/NotProperlyConfiguredException.php | 13 +++++++++++++ src/KavenegarApi.php | 13 ++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 src/Exceptions/NotProperlyConfiguredException.php diff --git a/src/Exceptions/NotProperlyConfiguredException.php b/src/Exceptions/NotProperlyConfiguredException.php new file mode 100644 index 0000000..81d2171 --- /dev/null +++ b/src/Exceptions/NotProperlyConfiguredException.php @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/src/KavenegarApi.php b/src/KavenegarApi.php index ff0e946..351e65a 100644 --- a/src/KavenegarApi.php +++ b/src/KavenegarApi.php @@ -5,27 +5,26 @@ use Kavenegar\Exceptions\ApiException; use Kavenegar\Exceptions\HttpException; use Kavenegar\Exceptions\RuntimeException; -use Kavenegar\Enums\ApiLogs ; +use Kavenegar\Exceptions\NotProperlyConfiguredException; +use Kavenegar\Enums\ApiLogs; use Kavenegar\Enums\General; class KavenegarApi { const APIPATH = "%s://api.kavenegar.com/v1/%s/%s/%s.json/"; const VERSION = "1.2.2"; - public function __construct($apiKey,$insecure=false) + public function __construct($apiKey, $insecure=false) { if (!extension_loaded('curl')) { - die('cURL library is not loaded'); - exit; + throw new NotProperlyConfiguredException('cURL library is not loaded'); } if (is_null($apiKey)) { - die('apiKey is empty'); - exit; + throw new NotProperlyConfiguredException('apiKey is empty'); } $this->apiKey = trim($apiKey); $this->insecure = $insecure; } - + protected function get_path($method, $base = 'sms') { return sprintf(self::APIPATH,$this->insecure==true ? "http": "https", $this->apiKey, $base, $method); From c82ae134cf00ec5c1bccccafcb605827b0b99dac Mon Sep 17 00:00:00 2001 From: Alireza Yusefi Date: Tue, 18 Jul 2023 14:53:24 +0330 Subject: [PATCH 08/11] Update KavenegarApi.php fix creation of dynamic property --- src/KavenegarApi.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/KavenegarApi.php b/src/KavenegarApi.php index ff0e946..25e26e1 100644 --- a/src/KavenegarApi.php +++ b/src/KavenegarApi.php @@ -12,6 +12,8 @@ class KavenegarApi { const APIPATH = "%s://api.kavenegar.com/v1/%s/%s/%s.json/"; const VERSION = "1.2.2"; + private $apiKey = ""; + private $insecure = false; public function __construct($apiKey,$insecure=false) { if (!extension_loaded('curl')) { @@ -291,4 +293,4 @@ public function CallMakeTTS($receptor, $message, $date = null, $localid = null) return $this->execute($path, $params); } } -?> \ No newline at end of file +?> From 41690ff674531b59f7989385eae12d9a1c3f0566 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Wed, 8 Nov 2023 11:53:16 +0330 Subject: [PATCH 09/11] remove ancient php 5.4 support --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1ba9d47..e1136b1 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": ">=5.4.0" + "php": ">=8.1" }, "autoload": { "psr-4": { From b4587f9cc2d7c35b10625a85abe5ef03952946e5 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Wed, 8 Nov 2023 12:18:01 +0330 Subject: [PATCH 10/11] add gitignore file --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b995777 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +vendor/ +.vscode/ +.idea/ From 7e39782939363313eeeed4b2acfa66e9108d18d8 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Wed, 8 Nov 2023 12:20:37 +0330 Subject: [PATCH 11/11] bump version to 2.0.0-dev --- README.md | 91 +++++++++++++++++++++----------------------- composer.json | 1 + src/KavenegarApi.php | 4 +- 3 files changed, 45 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index ba25d84..9630566 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# kavenegar-PHP +# Kavenegar-PHP [![Latest Stable Version](https://poser.pugx.org/kavenegar/php/v/stable.svg)](https://packagist.org/packages/kavenegar/php) -[![Total Downloads](https://poser.pugx.org/kavenegar/php/downloads.svg)](https://packagist.org/packages/kavenegar/php) +[![Total Downloads](https://poser.pugx.org/kavenegar/php/downloads.svg)](https://packagist.org/packages/kavenegar/php) # Kavenegar RESTful API Document If you need to future information about API document Please visit RESTful Document @@ -15,7 +15,7 @@ After that you just need to pick API-KEY up from receptor"; echo "date = $r->date"; echo "cost = $r->cost"; - } + } } } catch(\Kavenegar\Exceptions\ApiException $e){ @@ -69,51 +69,48 @@ catch(\Kavenegar\Exceptions\HttpException $e){ // در زمانی که مشکلی در برقرای ارتباط با وب سرویس وجود داشته باشد این خطا رخ می دهد echo $e->errorMessage(); } +``` -/* -sample output +Example output: +```json { - "return": - { - "status":200, - "message":"تایید شد" - }, - "entries": - [ - { - "messageid":8792343, - "message":"خدمات پیام کوتاه کاوه نگار", - "status":1, - "statustext":"در صف ارسال", - "sender":"10004346", - "receptor":"09123456789", - "date":1356619709, - "cost":120 - }, - { - "messageid":8792344, - "message":"خدمات پیام کوتاه کاوه نگار", - "status":1, - "statustext":"در صف ارسال", - "sender":"10004346", - "receptor":"09367891011", - "date":1356619709, - "cost":120 - } - ] + "return": { + "status": 200, + "message": "تایید شد" + }, + "entries": [ + { + "messageid": 8792343, + "message": "خدمات پیام کوتاه کاوه نگار", + "status": 1, + "statustext": "در صف ارسال", + "sender": "10004346", + "receptor": "09123456789", + "date": 1356619709, + "cost": 120 + }, + { + "messageid": 8792344, + "message": "خدمات پیام کوتاه کاوه نگار", + "status": 1, + "statustext": "در صف ارسال", + "sender": "10004346", + "receptor": "09367891011", + "date": 1356619709, + "cost": 120 + } + ] } -*/ ``` - ## Contribution -Bug fixes, docs, and enhancements welcome! Please let us know support@kavenegar.com +Bug fixes, documentation, and enhancements are welcome! Please let us know here: support@kavenegar.com
- + ## راهنما ### معرفی سرویس کاوه نگار @@ -122,11 +119,11 @@ Bug fixes, docs, and enhancements welcome! Please let us know - - diff --git a/composer.json b/composer.json index e1136b1..5ae2d73 100644 --- a/composer.json +++ b/composer.json @@ -2,6 +2,7 @@ "name": "kavenegar/php", "type": "library", "description": "A PHP wrapper for Kavenegar's API", + "version": "2.0.0-dev", "keywords": ["kavenegar", "sms", "api"], "homepage": "http://github.com/Kavenegar/kavenegar-php", "license": "MIT", diff --git a/src/KavenegarApi.php b/src/KavenegarApi.php index c5e8b47..e39a9e4 100644 --- a/src/KavenegarApi.php +++ b/src/KavenegarApi.php @@ -12,7 +12,7 @@ class KavenegarApi { const APIPATH = "%s://api.kavenegar.com/v1/%s/%s/%s.json/"; - const VERSION = "1.2.2"; + const VERSION = "2.0.0-dev"; private $apiKey = ""; private $insecure = false; public function __construct($apiKey, $insecure=false) @@ -189,7 +189,6 @@ public function Cancel($messageid) "messageid" => is_array($messageid) ? implode(",", $messageid) : $messageid ); return $this->execute($path,$params); - } public function Receive($linenumber, $isread = 0) @@ -294,4 +293,3 @@ public function CallMakeTTS($receptor, $message, $date = null, $localid = null) return $this->execute($path, $params); } } -?>