PHP code example of creativecrafts / laravel-twillio-sms

1. Go to this page and download the library: Download creativecrafts/laravel-twillio-sms 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/ */

    

creativecrafts / laravel-twillio-sms example snippets


return [
    'account_sid' => env('TWILIO_ACCOUNT_SID'),
    'auth_token' => env('TWILIO_AUTH_TOKEN'),
    'sms_from' => env('TWILIO_SMS_FROM'),
    // The Lookup v2 API allows you to query information on a phone number so that you can make a trusted interaction with your user.
    // With this, you can format and validate phone numbers with the free Basic Lookup request
    // and add on data packages to get even more in-depth carrier and caller information.
    // currently supported fields: 'line_type_intelligence', 'sms_pumping_risk' for more information
    'phone_number_lookup' => [
        'fields' => [
            'line_type_intelligence',
            'sms_pumping_risk',
        ],
        'sms_pumping_risk' => [
            // low risk: 0 - 59
            // mild risk: 60 - 74
            // moderate risk: 75 - 89
            // high risk: 90 - 100
            // visit https://www.twilio.com/docs/lookup/v2-api/sms-pumping-risk for more information
            'max_allowed_sms_pumping_risk_score' => 59,
        ],
    ],
];

use CreativeCrafts\LaravelTwillioSms\LaravelTwillioSms;

$sms = LaravelTwillioSms::init()
    ->setPhoneNumber('+1234567890')
    ->setMessage('Hello, this is a test message!')
    ->send();

if ($sms) {
    echo "Message sent successfully!";
} else {
    echo "Failed to send the message.";
}

public static function init(): self
bash
php artisan vendor:publish --tag="twillio-sms-config"