Skip to content

Commit

Permalink
add new send sms
Browse files Browse the repository at this point in the history
  • Loading branch information
mfrouh committed Mar 20, 2023
1 parent 8841d74 commit 22a421b
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions src/BaseClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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)
Expand Down

0 comments on commit 22a421b

Please sign in to comment.