Coder Social home page Coder Social logo

laravel-clicksend's Introduction

Very short description of the package

Latest Version on Packagist Total Downloads GitHub Actions

This is a laravel wrapper for ClickSend's REST API, currently only implementing sending SMS and getting delivery receipts for those messages.

Installation

You can install the package via composer:

composer require codemonkey76/laravel-clicksend

Config

Optionally you can publish the config file if you would like to modify the config.

php artisan vendor:publish --provider="Codemonkey76\ClickSend\ClickSendServiceProvider"

Environment

Add the following to your .env file and set the values from your clicksend account.

CLICKSEND_USERNAME=<your username goes here>
CLICKSEND_PASSWORD=<your api key goes here>

Optionally if you need to modify the api endpoint, you can also define the following.

CLICKSEND_API_ENDPOINT=*<api endpoint goes here>*

Usage

Example 1. Sending a single message and retreiving the delivery receipt.

use Codemonkey76\ClickSend\SmsMessage;

$recipient = '1234567890';
$senderId  = '1234567890';
$body      = 'Test Message';

$message = new SmsMessage($recipient, $senderId, $body);

$response = ClickSend::SendMessage($message);

// Some time later, get the receipt.
sleep(5);

ClickSend::GetMessageReceipt($response->data->messages[0]->message_id);

Example 2. Send multiple messages and retrieve their delivery receipts.

use Codemonkey76\ClickSend\SmsMessage;

$message1 = new SmsMessage('1234567890', '1234567890', 'Test Message #1');
$message2 = new SmsMessage('1234567890', '1234567890', 'Test Message #2');
$message3 = new SmsMessage('1234567890', '1234567890', 'Test Message #3');
$message4 = new SmsMessage('1234567890', '1234567890', 'Test Message #4');

$response = ClickSend::SendMessage([$message1, $message2, $message3, $message4]);

// Some time later, get the receipts.
sleep(5);

$receipt1 = ClickSend::GetMessageReceipt($response->data->message[0]->message_id);
$receipt2 = ClickSend::GetMessageReceipt($response->data->message[1]->message_id);
$receipt3 = ClickSend::GetMessageReceipt($response->data->message[2]->message_id);
$receipt4 = ClickSend::GetMessageReceipt($response->data->message[3]->message_id);

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

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

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.

laravel-clicksend's People

Contributors

arif98741 avatar codemonkey76 avatar popplestones 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.