feat: add otp sms
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class KavenegarService
|
||||
{
|
||||
public function sendVerify(string $mobile, string $token)
|
||||
{
|
||||
$apiKey = config('kave.api_key');
|
||||
|
||||
if (!$apiKey) {
|
||||
throw new \Exception('KAVE_API_KEY is null');
|
||||
}
|
||||
|
||||
$url = "https://api.kavenegar.com/v1/{$apiKey}/verify/lookup.json";
|
||||
|
||||
$response = Http::timeout(5)->get($url, [
|
||||
'receptor' => $mobile,
|
||||
'token' => $token,
|
||||
'template' => config('kave.template'),
|
||||
]);
|
||||
|
||||
logger()->info('Kavenegar raw', [
|
||||
'url' => $url,
|
||||
'status' => $response->status(),
|
||||
'body' => $response->body(),
|
||||
]);
|
||||
|
||||
return $response->json();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user