25 lines
528 B
PHP
25 lines
528 B
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use Twilio\Exceptions\TwilioException;
|
|
use Twilio\Rest\Client;
|
|
|
|
class TwilioService
|
|
{
|
|
private Client $client;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->client = new Client(config('services.twilio.sid'), config('services.twilio.token'));
|
|
}
|
|
|
|
/**
|
|
* @throws TwilioException
|
|
*/
|
|
public function sendSms(string $to, string $message): void
|
|
{
|
|
$this->client->messages->create($to, ['from' => config('services.twilio.from'), 'body' => $message]);
|
|
}
|
|
}
|