PHP code example of travisjryan / twilio

1. Go to this page and download the library: Download travisjryan/twilio 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/ */

    

travisjryan / twilio example snippets


'Twilio' => 'Aloha\Twilio\Support\Laravel\Facade',

use Twilio;

Twilio::message($user->phone, $message);

Twilio::from('call_center')->message($user->phone, $message);
Twilio::from('board_room')->message($boss->phone, 'Hi there boss!');

$twilio = new Aloha\Twilio\Twilio($accountId, $token, $fromNumber);

$twilio->message('+18085551212', 'Pink Elephants and Happy Rainbows');

$twilio->call('+18085551212', 'http://foo.com/call.xml');

$twilio->call('+18085551212', function (\Twilio\TwiML\VoiceResponse $message) {
    $message->say('Hello');
    $message->play('https://api.twilio.com/cowbell.mp3', ['loop' => 5]);
});

$message = new \Twilio\TwiML\VoiceResponse();
$message->say('Hello');
$message->play('https://api.twilio.com/cowbell.mp3', ['loop' => 5]);

$twilio->call('+18085551212', $message);

$sdk = $twilio->getTwilio();

$sdk = Twilio::getTwilio();

$twilio->message($to, $message, $mediaUrls, $params);
// passes all these params on.

$twilio->call($to, $message, $params);
// passes all these params on.

if (getenv('APP_ENV') === 'production') {
    $twilio = $container->make(\Aloha\Twilio\Manager::class);
} else {
    $psrLogger = $container->make(\Psr\Log\LoggerInterface::class);
    $twilio = new LoggingDecorator($psrLogger, new \Aloha\Twilio\Dummy());
}

// Inject it wherever you want.
$notifier = new Notifier($twilio);
shell
php artisan vendor:publish --provider="Aloha\Twilio\Support\Laravel\ServiceProvider"