1. Go to this page and download the library: Download kevupton/twilavel library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kevupton / twilavel example snippets
// add directly from the app
$app->register(\Kevupton\Twilavel\Providers\TwilavelServiceProvider::class);
'providers' => [
// Other Service Providers
\Kevupton\Twilavel\Providers\TwilavelServiceProvider::class,
],
return array(
// set to true to prevent the
'log_override' => env('TWILIO_LOG_OVERRIDE', false),
// Your Account SID and Auth Token from twilio.com/console
'sid' => env('TWILIO_SID'),
'token' => env('TWILIO_TOKEN'),
// the default from which messages will be sent from
'from' => env('TWILIO_FROM', 'Twilavel'),
);
namespace App\Twilio\Messages;
use \Kevupton\Twilavel\Messages\Message;
use App\Models\User;
class VerifyPhone extends Message {
const FROM = '+61123456789';
/** @var string custom verification code */
private $code;
public function __construct(User $user, $mobile = null)
{
// use mobile other use user mobile
$number = $mobile?: $user->mobile;
parent::__construct($number, self::FROM);
// get a random code
$this->code = $user->generateMobileVerificationCode($number);
}
public function getBody()
{
return 'Your verification code: ' . $this->code;
}
}