PHPackages                             asterism/twilio - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. asterism/twilio

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

asterism/twilio
===============

SMS sending using Twilio

02PHP

Since Feb 3Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Krunaldabhi/AsterismTwilio)[ Packagist](https://packagist.org/packages/asterism/twilio)[ RSS](/packages/asterism-twilio/feed)WikiDiscussions main Synced 6d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel - Twilio
================

[](#laravel---twilio)

[Wiki on web](http://asterism.github.io/plivo/)

[![Latest Stable Version](https://camo.githubusercontent.com/80669c45f607af3561a719aa49dec9f4752196f22d15a83fd5ed9d349cf791b0/68747470733a2f2f706f7365722e707567782e6f72672f617374657269736d6d2f7477696c696f2f762f737461626c65)](https://packagist.org/packages/asterismm/twilio)[![Total Downloads](https://camo.githubusercontent.com/b09b9c214f8683ec85eb7ada3ee979c5e415bb517562f4bd4edf9a4a3a3feb50/68747470733a2f2f706f7365722e707567782e6f72672f617374657269736d6d2f7477696c696f2f646f776e6c6f616473)](https://packagist.org/packages/asterismm/twilio)[![Latest Unstable Version](https://camo.githubusercontent.com/9f20e99c7d1f024e772a78dcdabf167f13730c20866b62370f0467caeb79eb7d/68747470733a2f2f706f7365722e707567782e6f72672f617374657269736d6d2f7477696c696f2f762f756e737461626c65)](https://packagist.org/packages/asterismm/twilio)[![License](https://camo.githubusercontent.com/37e357ae88fe59c6eeedfcdfc54fb47434d82b0ff76fd199dd559cbd7e35c0cc/68747470733a2f2f706f7365722e707567782e6f72672f617374657269736d6d2f7477696c696f2f6c6963656e7365)](https://packagist.org/packages/asterismm/twilio)[![Monthly Downloads](https://camo.githubusercontent.com/15784eb85acb31e62c3ec2c90d4af9ab7f6be3062944c01ccc4e7e95a006cbbd/68747470733a2f2f706f7365722e707567782e6f72672f617374657269736d6d2f7477696c696f2f642f6d6f6e74686c79)](https://packagist.org/packages/asterismm/twilio)[![Daily Downloads](https://camo.githubusercontent.com/13eaf763d6bc96a13b971a55296792e3d27e219a9c563ca2c070faa2fe3d37b2/68747470733a2f2f706f7365722e707567782e6f72672f617374657269736d6d2f7477696c696f2f642f6461696c79)](https://packagist.org/packages/asterismm/twilio)[![composer.lock](https://camo.githubusercontent.com/c0838184474f500bb86abc4807a664d9d20d9ceb02d01d724b8bcc10da696db0/68747470733a2f2f706f7365722e707567782e6f72672f617374657269736d6d2f7477696c696f2f636f6d706f7365726c6f636b)](https://packagist.org/packages/asterismm/twilio)

INDEX
-----

[](#index)

IndexDescription[What it is](https://github.com/asterism/twilio/blob/master/README.md#what-it-is)- Introduction[Installation](https://github.com/asterism/twilio/blob/master/README.md#installation)- Installing Twilio package[Laravel Integration](https://github.com/asterism/twilio/blob/master/README.md#laravel-integration)- Integrating this package with Laravel application[Docs](https://github.com/asterism/twilio/blob/master/README.md#method-available-parameters-and-responses)- Description of methods available and parameters etc [Method](https://github.com/asterism/twilio/blob/master/README.md#method) [Responses](https://github.com/asterism/twilio/blob/master/README.md#responses)[Miscellaneous](https://github.com/asterism/twilio/blob/master/README.md#miscellaneous)- Miscellaneous content regarding method calls[Invalid method calls](https://github.com/asterism/twilio/blob/master/README.md#invalid-method-calls)- Invalid arguments (Not supported)[Sending SMS](https://github.com/asterism/twilio/blob/master/README.md#sending-sms)- A simple Examp to illustarte the using this package[Example with Laravel](https://github.com/asterism/twilio/blob/master/README.md#example-code-for-laravel-along-with-sample-env-file)- Sample code in Laravel[Exception Handling](https://github.com/asterism/twilio/blob/master/README.md#handling-exceptions)- An Exception Handling mechanism to catch errors[Twilio](https://github.com/asterism/twilio/blob/master/README.md#twilio-trail-account-usage)- How to Get registered on Twilio to use free trail account[License](https://github.com/asterism/twilio/blob/master/README.md#licence)- License\##WHAT IT IS?

- This package is used to send sms to any mobile number.
- This uses [Twilio](https://www.twilio.com/) API.
- It requires *AccountSID* and *AuthToken*, they can be generated by registrting @at [Twilio](https://www.twilio.com/try-twilio)
    - after registration click on Account ,there you will be able to see authsid and authtoken.
    - You have assigned a sender mobile number which can be found at [Twilio](https://www.twilio.com/user/account/phone-numbers/incoming),which is used to send Text Messages or MMS and ShortCodes etc.

---

\##INSTALLATION

- Download package form  .
- OR YOU CAN RUN FOLLOWING COMMAND FROM TERMINAL
- With composer you can run this line **composer require asterism/twilio**

Run this command from the Terminal:

```
    composer require asterism/twilio
    composer dumpautoload
    composer update
```

---

\##LARAVEL INTEGRATION

you need to add the service provider. Open `app/config/app.php`, and add a new item to the providers array.

```
  asterism\Twilio\TwilioServiceProvider::class,
```

Then, add a Facade for more convenient usage. In `app/config/app.php` add the following line to the `aliases` array:

```
  'Twilio'    => asterism\Twilio\Facade\Twilio::class,
```

Again do composer update

---

METHOD, AVAILABLE PARAMETERS AND RESPONSES
------------------------------------------

[](#method-available-parameters-and-responses)

\#####Method

```
message(array, string, boolean, boolean, boolean)
```

```
    $message_array = array(
        'sender_id'     => 'TWILIO_AUTH_SID',
        'sender_secret' => 'TWILIO_AUTH_SECRET',
        'reciver_mobile' => 'MOBILE_NUMBER',
        'media_url' => 'MEDIA_URL',
        'otp'     =>'OTP',
        'sender' => 'TWILIO_SOURCE_NUMBER'
    );

```

##### The message\_array parameters

[](#the-message_array-parameters)

PARAMETERDESCRIPTIONsender\_idThis is the key defined in ".env" file for auth\_sidsender\_secretThis is the key defined in ".env" file for auth\_secretsenderThis is the key defined in .env file for sender mobile numberreciver\_mobileThis is the receivers mobile numbermedia\_urlThis is the "uri" for mutimediaotpThis key values associates with the otp##### Responses

[](#responses)

CODEDESCRIPTION16000Error due to all flags are set to false or no flag was set16001Error due to all flags were set to true16002No sms type was set witin the avialbel list of flag parameters16003Un handled error---

\##MISCELLANEOUS

\#####To send SMS

```
  Twilio::message($message_array,$op="only msg", true,  false, false ); // sms
```

\#####To send MMS

```
  Twilio::message($message_array,$op="only MMS", false, false, true  ); // media
```

\#####To send OTP

```
  Twilio::message($message_array,$op="only verfication code", false, true,  false ); // otp
```

\#####To send both SMS and MMS

```
  Twilio::message($message_array,$op="This is combaination both SMS and MMS", true,  false, true  ); // sms , media
```

\#####INVALID METHOD CALLS

```
Twilio::message($message_array,$op="All set to true sms,mms,otp", true,  true,  true  ); // sms , otp , media
Twilio::message($message_array,$op="all set to false", false, false, false );            // none defined
Twilio::message($message_array,$op="all considered to be false");                        // none defined
Twilio::message($message_array);
```

---

\##SENDING SMS

```
