Laravel Twillio API Integration
twilio:sms
twilio:call
Begin by installing this package through Composer. Run this command from the Terminal:
composer require aloha/twilio 1.0.2
To wire this up in your Laravel project, you need to add the service provider. Open app/config/app.php
, and add a new item to the providers array.
'Aloha\Twilio\Support\Laravel\ServiceProvider',
Then, add a Facade for more convenient usage. In app/config/app.php
add the following line to the aliases
array:
'Twilio' => 'Aloha\Twilio\Facades\Twilio',
Edit services.php
in your config folder with your appropriate Twilio settings. Example config can be found in this file.
Sending a SMS Message
<?php
Twilio::message('+18085551212', 'Pink Elephants and Happy Rainbows');
Creating a Call
<?php
Twilio::call('+18085551212', 'http://foo.com/call.xml');
Generating TwiML
<?php
$twiml = Twilio::twiml(function($message) {
$message->say('Hello');
$message->play('https://api.twilio.com/cowbell.mp3', array('loop' => 5));
});
print $twiml;
laravel-twilio is open-sourced software licensed under the MIT license