Skip to content

oliveris/text

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Text

Sends text messages to a provider specified.

The default driver is set to Twilio which will expand eventually to pull in other service providers.

Usage

Pull in the composer package by running the command below:

composer require oliveris/text

Import the Text namespace into the class (autoloading)

use Text\Text;

Examples

Environment variables

If the env method is available from your application you can set the env variables, see example below:

// TWILIO SPECIFIC SETTINGS
TWILIO_SID={sid_from_twilio}
TWILIO_TOKEN={token_from_twilio}
// may want to set the inbound number
TWILIO_INBOUND_NUMBER={number_that_captures_inbound_sms}

If the env method is not available, see example below to set them using an alternate method:

$text = Text::getDriver("twilio");
$text->setSid(***********);
$text->setToken(************);
// may want to set the inbound number
$text->setInboundNumber(************);

Sending a SMS

The following example shows how you can send a simple SMS

$text = Text::getDriver("twilio");
$text->setBody('Lorem ipsum dolor sit amet, mnesarchum interpretaris vis eu.');
$text->setTo('+447*********');
$text->setFrom(env('TWILIO_NUMBER'));
$text->send();

Sending a MMS

The following example shows how you can can send a simple MMS

Noticed how this may display differently dependent on device. (iphone/android)

$text = Text::getDriver("twilio");
$text->setBody('Lorem ipsum dolor sit amet, mnesarchum interpretaris vis eu.');
$text->setMedia('url_to_media');
$text->setTo('+447*********');
$text->setFrom(env('TWILIO_NUMBER'));
$text->send();

Getting the inbound SMS

To get all of the inbound texts sent to the number

$text = Text::getDriver("twilio");
$text->setBody('Lorem ipsum dolor sit amet, mnesarchum interpretaris vis eu.');
$text->setTo('+447*********');
$text->setFrom(env('TWILIO_NUMBER'));
$text->send();

Built With

  • PHP 7

Versioning

We use Semantic Versioning 1.0.0, for example v1.0.0.

Authors

  • Sam Oliveri - Software Engineer

License

Text is open-sourced software licensed under the MIT license.

About

Texting service

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages