| Server IP : 34.87.99.72 / Your IP : 216.73.217.31 Web Server : Apache/2.4.46 (Unix) OpenSSL/1.1.1n System : Linux zlock-bitnami-lamp-prod-v2-vm 4.19.0-16-cloud-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 User : bitnami ( 1000) PHP Version : 7.4.18 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /opt/bitnami/apache/htdocs/app/app/Http/Services/ |
Upload File : |
<?php
namespace App\Http\Services;
use App\Http\Services\GeoZoneService;
use Twilio\Rest\Client;
use Pylon\Exceptions\BadRequestException;
class TwilioService{
public function __construct(
)
{
}
public function sendSms(Array $request)
{
try{
$token = config('services.twilio.twilioAuth');
$twilio_sid = config('services.twilio.twilioSid');
$twilio_verify_sid = config('services.twilio.twilioVerifySid');
$twilio_mobile_num = config('services.twilio.twilioMobileNum');
$twilio = new Client($twilio_sid, $token);
$message = $twilio->messages->create(
// the number you'd like to send the message to
$request['collector_num'],
[
// A Twilio phone number you purchased at twilio.com/console
'from' => $twilio_mobile_num,
// the body of the text message you'd like to send
'body' => $request['message']
]
);
return true;
}
catch(\Exception $e){
// if($e->getCode() == 21608)
// throw (new BadRequestException('Error sending message to unverified phone number.'))
// ->withErrorType('Error sending message to unverified phone number.');
// else
// throw (new BadRequestException('Something went wrong when sending sms message'))
// ->withErrorType('Something went wrong when sending sms message');
}
}
}