From 22a421b107a7968991d6b6a76fd21ae6376a69b8 Mon Sep 17 00:00:00 2001 From: mfrouh Date: Mon, 20 Mar 2023 14:43:06 +0200 Subject: [PATCH] add new send sms --- src/BaseClass.php | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/BaseClass.php b/src/BaseClass.php index 921dd69..698ea77 100644 --- a/src/BaseClass.php +++ b/src/BaseClass.php @@ -8,6 +8,7 @@ class BaseClass { const Base_Url = 'https://4jawaly.net/api'; + const Base_Url_New = 'https://api-sms.4jawaly.com/api/v1/account/area/sms/send'; public function getBalance() { @@ -28,23 +29,16 @@ public function getBalance() public function sendSms($message, $phoneNumber, $phoneCode) { - try { - $data = [ - 'username' => config('sms4jawaly.username'), - 'password' => config('sms4jawaly.password'), - "message" => $message, - "numbers" => '+' . $phoneCode . $this->convertArabicNumbers(ltrim($phoneNumber, '0')), - "sender" => config('sms4jawaly.sender_name'), - "unicode" => 'e', - 'return' => 'json' - ]; + $messages = []; + $messages["messages"] = []; + $messages["messages"][0]["text"] = $message; + $messages["messages"][0]["numbers"][] = $phoneCode . $this->convertArabicNumbers(ltrim($phoneNumber, '0')); + $messages["messages"][0]["sender"] = config('sms4jawaly.sender_name'); - $response = Http::withOptions(['verify' => false])->get(self::Base_Url . '/sendsms.php', $data); + $response = Http::withBasicAuth(config('sms4jawaly.username'), config('sms4jawaly.password')) + ->post(self::Base_Url_New, $messages); - return json_decode($response); - } catch (Exception $error) { - return $error; - } + return json_decode($response); } private function convertArabicNumbers($number)