Download the PHP package allanvb/laravel-semysms without Composer
On this page you can find all versions of the php package allanvb/laravel-semysms. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download allanvb/laravel-semysms
More information about allanvb/laravel-semysms
Files in allanvb/laravel-semysms
Package laravel-semysms
Short Description SemySMS integration for Laravel
License MIT
Homepage https://github.com/allanvb/laravel-semysms
Informations about the package laravel-semysms
Laravel package for SMS mailing service SemySMS
Package that integrates SemySMS API into your Laravel 5 app.
Installation:
Laravel 5.5+
If you're using Laravel 5.5 or above, the package will automatically register provider and facade.
Laravel 5.4 and below
Add Allanvb\LaravelSemysms\SemySmsServiceProvider to the providers array in your config/app.php:
Add an alias in your config/app.php:
Or you can use the facade class when needed:
Overview
Look at one of the following topics to learn more about SemySMS package.
- Configuration
- Usage
- Examples
- Events
- Notification channel
- Exceptions
- Extra
Configuration
You can use php artisan vendor:publish to copy the configuration file to your app's config directory:
Then update config/semy-sms.php with your credentials. Also you can update your .env file with the following:
All methods uses Validator to validate passed data.
By default, methods will try to use for all requests the device you specified in your SEMYSMS_DEVICE_ID variable.
Usage:
To use the SemySMS Library you can access the facade, or request the instance from the service container:
Or
- All numbers must have international format.
All methods and events will return a Collection, so you can use all available methods to manipulate response.
For example: SemySMS::getInbox()->sortByDesc('date');
Examples
Sending simple message
Available parameters:
to- (string) Phone number in international format (required).text- (string) SMS Text, max 255 symbols (required).device_id- (string) Device ID or active.
device_id parameter can also take the active value which means that the service will distribute new SMS between all your active devices.
Sending multiple messages
Available parameters:
to- (array) List of phones in international format (required).text- (string) SMS Text, max 255 symbols (required).
In case you want to have more control on sending multiple messages you can use chaining methods.
Available parameters:
to- (string) Phone number in international format (required).text- (string) SMS Text, max 255 symbols (required).device_id- (int) Device ID.my_id- (string) SMS code from your accounting system
Sending USSD requests
- This feature works only on Android 8.0+
You can use 'device_id' parameter to perform USSD request from specific device.
List of outgoing SMS
Optional, you can specify a interval of time you want to get by using Interval helper like this.
List of incoming SMS
Delete outgoing SMS
Delete incoming SMS
deleteOutbox() and deleteInbox() methods will return deleted messages.
Optional, you can use filter for getOutbox(), getInbox(), deleteOutbox() and deleteInbox() methods.
Available parameters:
interval- (Interval) Interval of time.device_id- (int) Device ID.start_id- (int) Start ID of list filter.end_id- (int) End ID of list filter.list_id- (array) List of SMS codes.phone- (string) Phone number.
List of devices
By default this method will return list of all devices connected to account.
Available parameters:
status- (string) active|archived.list_id- (array) List of devices.
Cancel sending SMS
This method will cancel all SMS which was not sent to your default device.
You can request canceling of all SMS for specific device by passing device_id, or specific message by passing sms_id to array.
Events
The package have events built in. There are three events available for you to listen for.
| Event | Fired | Parameter |
|---|---|---|
| semy-sms.sent | When message sent. | 'To' and 'text' parameters of SMS that was sent. |
| semy-sms.sent-multiple | When multiple message sent. | List of phones, devices and message that was sent. |
| semy-sms.received | When new message income. | DeviceID, Sender and Text of income message. |
| semy-sms.ussd-response | When ussd response income. | DeviceID, Sender and Text of income message. |
Notification channel
This package also provide notification channel for SemySMS.
To use notification channel you must use SemySmsChannel::class in via method of your notification class.
After that you will be able to use toSemySms() method for sending messages.
See example below.
You can add recipient in two ways.
-
First is by using
routeNotificationForSemySMS()in your notifiable model as below. - Second way is to use
to()method inside your notification.
If you'll use both, then to() method will be used as primary.
Exceptions
The package can throw the following exceptions:
| Exception | Reason |
|---|---|
| SemySmsValidationException | When method params don't pass validation. |
| RequestException | When HTTP response will be different than 200. |
| SmsNotSentException | When something went wrong with the request to SemySMS servers. |
| InvalidIntervalException | When you pass invalid Interval |
Extra
Receiving message from devices
If you want to get incoming messages from your devices, you can use
https://yourdomain.com/semy-sms/receive route in your SemySMS control panel.
To get this route working you need make some actions:
- Change
catch_incomingtotruein your config file. - Add
semy-sms/receiveroute to your$exceptvariable inVerifyCsrfTokenmiddleware.
After that, you will be able to listen for semy-sms.received Event.
If you performed an ussd request, you can listen for semy-sms.ussd-response Event to process USSD response.
In case that you get USSD response as SMS, you can add sender name to ussd_senders in your config file.
You can get more information about Events in Laravel official documentation
Intervals
Interval class offers the following methods: hours(), days(), weeks(), months() and years().
If you want to have more control on Interval you can pass a startDate and an endDate to the object.
License
The MIT License (MIT). Please see License File for more information.