From acadd8c9a4ceb854e7f105a0e03c46f1c8c59566 Mon Sep 17 00:00:00 2001 From: Nurmuhammet Allanov Date: Mon, 27 Oct 2025 21:02:26 +0500 Subject: [PATCH] sms use bank --- .../Sms/Repositories/SmsRepository.php | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/app/Modules/Sms/Repositories/SmsRepository.php b/app/Modules/Sms/Repositories/SmsRepository.php index 9a8443f..b1eb065 100644 --- a/app/Modules/Sms/Repositories/SmsRepository.php +++ b/app/Modules/Sms/Repositories/SmsRepository.php @@ -3,8 +3,8 @@ namespace App\Modules\Sms\Repositories; use Exception; -use Illuminate\Http\Client\PendingRequest; -use Illuminate\Support\Facades\Http; +use GuzzleHttp\Client; +use GuzzleHttp\Psr7\Request as GuzzleRequest; use Illuminate\Support\Facades\Log; class SmsRepository @@ -18,23 +18,29 @@ class SmsRepository return true; } - $response = Http::retry( - times: 3, - sleepMilliseconds: 50, - throw: false, - when: function (Exception $exception, PendingRequest $request) { - Log::error('Exception: ', [ - 'message' => $exception->getMessage(), - 'line' => $exception->getLine(), - ]); + $client = new Client; + $headers = [ + 'Content-Type' => 'application/json;charset=utf-8;', + 'Charset' => 'UTF-8', + ]; + $body = 'JSON={ + "SendRequest": { + "TerminalID": "Online_PANEL", + "Version": "1", + "Lang": "EN", + "MobilePhone": "993'.$phone.'", + "Text": "'.$message.'" + } + }'; + // 10.3.158.103 + $request = new GuzzleRequest('POST', 'http://10.3.158.28:8080/kpsmsroute/online.request', $headers, $body); - return true; - }) - ->post(config()->string('module.sms.url'), [ - 'phone' => '+993'.$phone, - 'code' => $message, - ]); + try { + $res = $client->sendAsync($request)->wait(); - return $response->body(); + return $res->getBody(); + } catch (Exception $e) { + Log::error($e); + } } }