Git Product home page Git Product logo

php-bulk-sms's Introduction

BulkSMS API - PHP implementation

A simple implementation of BulkSMS for PHP.

Includes functionality to send single or batch messages.

Installation

This package requires PHP 5.4 because I'm too lazy to type array(). Sorry.

Using composer: composer require anlutro/bulk-sms - list of versions is available through GitHub's tag list.

Laravel

The package includes files to make usage super easy in Laravel 4 and higher.

  1. Add anlutro\BulkSms\Laravel\BulkSmsServiceProvider to the list of providers in app/config/app.php.
  2. Run php artisan config:publish anlutro/bulk-sms. Edit the config file in app/config/packages/anlutro/bulk-sms and fill in your username and password.
  3. (optional) Add an alias for the facade by adding 'BulkSms' => 'anlutro\BulkSms\Laravel\BulkSms' to aliases in app/config/app.php.

Credentials

To use this library you need create an account with Bulksms. They support several sub-sites for specific regions.

  1. Username : Bulksms login
  2. Password : Bulksms login password
  3. Baseurl : Bulksms sub-site to connect to (e.g. "http://bulksms.com" or "http://bulksms.de")

Usage

Send Single Message

$bulkSms = new anlutro\BulkSms\BulkSmsService('username', 'password', 'baseurl');
$bulkSms->sendMessage('12345678', 'Hello there!');

Send Bulk Message

$message1 = new \anlutro\BulkSms\Message("12345678", "Hi there");
$message2 = new \anlutro\BulkSms\Message("12345678", "Hello again");
$bulkSms = new anlutro\BulkSms\BulkSmsService('username', 'password', 'baseurl');
$bulkSms->sendMessage(array($message1,$message2));

Get Status report

$bulkSms = new anlutro\BulkSms\BulkSmsService('username', 'password', 'baseurl');
$bulkSms->getStatusForBatchId(693099785);

Send test messages

BulkSms suports test modes (SUCCESS and FAIL) that validate the message and return defined responses without really sending out SMS. In order to send messages in test mode, run the following:

Send message that will return a success:

$bulkSms = new anlutro\BulkSms\BulkSmsService('username', 'password', 'baseurl');
$bulkSms->setTestMode(\anlutro\BulkSms\BulkSmsService::TEST_ALWAYS_SUCCEED);
$bulkSms->getStatusForBatchId(693099785);

Send message that will return a failure response - and thus trigger a BulkSmsException :

$bulkSms = new anlutro\BulkSms\BulkSmsService('username', 'password', 'baseurl');
$bulkSms->setTestMode(\anlutro\BulkSms\BulkSmsService::TEST_ALWAYS_FAIL);
$bulkSms->getStatusForBatchId(693099785);

In Laravel, you don't need to construct $bulkSms, and you can replace $bulkSms-> with BulkSms:: provided you followed the installation steps above.

Contact

Open an issue on GitHub if you have any problems or suggestions.

License

The contents of this repository is released under the MIT license.

php-bulk-sms's People

Contributors

anlutro avatar gawonmi avatar jedimdan avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.