oliveris/text

Sends text messages to a provider specified.

Maintainers

Details

github.com/oliveris/text

Source

Issues

Installs: 5

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

Type:package

v1.0.0 2018-08-28 15:40 UTC

This package is auto-updated.

Last update: 2024-09-18 02:36:28 UTC


README

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.