netsplit/textlocal

A generic Textlocal SMS library

1.1.1 2018-07-05 11:26 UTC

This package is not auto-updated.

Last update: 2024-04-05 19:26:05 UTC


README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

Install

Via Composer

$ composer require netsplit/textlocal

Usage

$textlocal = new Netsplit\Textlocal(
    'https://path.to.textlocal.com/api2',
    'api-key-here'
);

Send an SMS message

API documentation for the "send" endpoint.

$response = $textlocal->sendSMS('Message content', [
    // Array of mobile numbers
    '07777777777',
    '07777777778',
], [
    // Optional values
    'containsTrackingLinks' => false,                  // Should URLs in the SMS be minified?
    'custom'                => 'Any string',           // For use as a reference
    'groupID'               => 5,                      // A Textlocal group ID
    'receiptURL'            => 'http://[...]',         // Custom receipt URL
    'scheduleAt'            => 1530735900,             // Unix timestamp - send the SMS at this time
    'sender'                => 'Optional Sender Name',
    'sendToOptOut'          => false,                  // Should the SMS be sent to users who have opted out?
    'simpleReply'           => false,                  // Disregard sender
    'test'                  => true,                   // Don't really send the SMS
    'unicode'               => false,                  // Does the SMS contain unicode characters?
    'validUntil'            => 1530735994,             // Unix timestamp - disregard the SMS at this time
]);

// Access values from the response:
echo $response->getStatus()->__toString(); // Hopefully "success"!
echo $response->getBalance()->getValue();

Shorten a URL

API documentation for the "short URL" endpoint

$response = $textlocal->getShortURL('https://www.google.com');
$shortURL = $response->getShortURL()->__toString();

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email mike@netsplit.org.uk instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.