sms use bank

This commit is contained in:
2025-10-27 21:02:26 +05:00
parent 79c4bb0c24
commit acadd8c9a4

View File

@@ -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);
}
}
}