https://github.com/khalidsheet/oursms-laravel
oursms.app client library that allows you to send SMS
https://github.com/khalidsheet/oursms-laravel
Last synced: 6 months ago
JSON representation
oursms.app client library that allows you to send SMS
- Host: GitHub
- URL: https://github.com/khalidsheet/oursms-laravel
- Owner: khalidsheet
- Archived: true
- Created: 2021-06-08T20:40:07.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2022-08-27T14:02:35.000Z (almost 4 years ago)
- Last Synced: 2026-01-11T14:53:21.396Z (6 months ago)
- Language: PHP
- Size: 11.7 KB
- Stars: 11
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Oursms laravel client
[](https://www.codacy.com/gh/khalidsheet/oursms-laravel/dashboard?utm_source=github.com&utm_medium=referral&utm_content=khalidsheet/oursms-laravel&utm_campaign=Badge_Grade)
[https://oursms.app](https://oursms.app) client library that allows you to send SMS
## Installation
Install oursms client with composer
```bash
composer require khalidsheet/oursms
```
**Skip this if you are running laravel version 5.5 or later**
The package will be auto-discovered
Otherwise run this command
**Step 1** - Publish the package config file under `config/oursms.php`
```bash
php artisan vendor:publish --provider="Khalidsheet\Oursms\OursmsServiceProvider" --tag="config"
```
**Step 2** - Go to the application `.env` and paste these variables in the end of the file.
```bash
OURSMS_USER_ID=""
OURSMS_KEY=""
```
## Usage/Examples
Import the package
```php
use Khalidsheet\Oursms\Oursms
```
In your controller instantiate a new instance from ```Oursms Client```
```php
$oursmsClient = new Oursms();
```
If you wish to send a single message
```php
$oursmsClient->sendMessage(string $to, string $message);
```
If you wish to send Otp message
```php
$oursmsClient->sendOtp(string $to, string $otp);
```
If you wish to check the status of your message
```php
$oursmsClient->getSmsStatus(string $messageId);
```
**Notice:** ``to`` is the phone number, ``message`` is the actuall mesasge that will be send to the user.
## Trait Usage/Examples
Also, you can use trait to send SMS or OTP messages to a user
Add the **Messageable** trait to your model.
```php
use Khalidsheet\Oursms\Traits\Messageable;
class User extends Model {
use Messageable;
...
}
```
Now you can use it like this
```php
$user = User::find(1);
// Sending OSM
$user->sendMessage(string $message);
// Sending OTP
$user->sendOtp(string $otp);
```
**Notice:** Trait functionality only available from version **1.1.0** or later
## Authors
- [@khalidsheet](https://www.github.com/khalidsheet)
## License
[MIT](https://choosealicense.com/licenses/mit/)