Laravel Twilio API Wrapper
New update is comming! (Using PHP chaining)
A Laravel 5.3+ wrapper for sending messages or calls with the Twilio API., (*1)
Setting up
You can install the package via composer:, (*2)
composer require sigfriedseldeslachts/twiliosms
Then, add the service provider and the alias, (*3)
// File: config/app.php
'providers' => [
...
Sigfriedseldeslachts\twiliosms\TwilioSMSServiceProvider::class,
...
];
'aliases' => [
...
'Twillio' => Sigfriedseldeslachts\twiliosms\Facades\Twilio::class,
...
];
After that you'll have to add a few lines to your .env file:, (*4)
TWILIO_SID=Your Twilio SID Token
TWILIO_TOKEN=Yout Twilio Token
TWILIO_NUMBER=Your twilio phone number, without +
And now you're ready to go!, (*5)
Usage
Global note
Removing the '+' from a phone number is not required as the plugin wil remove this automatically., (*6)
Sending a text message (SMS)
Twilio::SMS(string $to, string $message);
If you want to use a different phone number to send the text from:, (*7)
Twilio::SMS(string $to, string $message, string $from);
Example
Twilio::SMS('+123456789', 'Hello from Laravel!', '+987456321');
Sending a text message with image (MMS)
The image url needs to be a jpeg, gif or png file., (*8)
Twilio::MMS(string $to, string $message, string $url);
If you want to use a different phone number to send the text from:, (*9)
Twilio::MMS(string $to, string $message, string $url, string $from);
Example
Twilio::MMS('+123456789', 'Hello from Laravel!', 'http://www.hookinfo.com/wp-content/uploads/2016/08/laravel-1.png', '+987456321');
Making a call
To make a call you need to have a valid TwiML which needs to be a url. See the example below., (*10)
Twilio::Call(string $to, string $url);
If you want to use a different phone number to call from:, (*11)
Twilio::Call(string $to, string $url, string $from);
Example
Twilio::Call('+123456789', 'http://demo.twilio.com/docs/voice.xml', '+987456321');
Contributing
Feel free to help me out ;), (*12)
Security issue
If the security issue is related to the wrapper please contact me with my email: sigfriedseldeslachts@gmail.com, if it's an Twilio API issue please contact them., (*13)
License
MIT License, see license file for more info., (*14)