https://github.com/sysborg/kingsms-laravel
https://github.com/sysborg/kingsms-laravel
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/sysborg/kingsms-laravel
- Owner: sysborg
- License: mit
- Created: 2025-03-26T18:31:30.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-07-19T21:37:46.000Z (11 months ago)
- Last Synced: 2025-10-28T11:54:57.504Z (7 months ago)
- Language: PHP
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# KingSMS Laravel Package
Easily integrate [KingSMS](https://www.kingsms.com.br/) into your Laravel application.
This package simplifies the process of sending SMS, retrieving reports, checking balance, and receiving replies using the KingSMS API.
---
## 📦 Installation
Install the package via Composer:
```bash
composer require sysborg/kingsms
```
The service provider is auto-discovered by Laravel, so no need to manually add it to `config/app.php`.
---
## ⚙️ Configuration
Add your KingSMS credentials to your `.env` file:
```env
KINGSMS_URL=https://painel.kingsms.com.br/kingsms/api.php
KINGSMS_LOGIN=your_login
KINGSMS_TOKEN=your_token
```
The default API URL is already set, but you can override it if needed.
---
## 🚀 Usage
### Send SMS
```php
use Facades\Sysborg\KingSMS\Services\KingSMS;
$response = KingSMS::sendSMS(
'5598999999999', // Recipient phone number
'Your message goes here', // Message content
'Optional Campaign Name',
'Optional Date (dd/mm/yyyy)',
'Optional Time (hh:mm)'
);
```
### Get SMS Report
```php
$response = KingSMS::getRelatorio('your_sms_id');
```
### Check Balance
```php
$response = KingSMS::getSaldo();
```
### Get SMS Replies
```php
$response = KingSMS::getResposta('read'); // or 'unread'
```
---
## 🔔 Using as Notification Channel
You can also send SMS using Laravel's notification system.
### 1. Add `toKingsms()` method in your Notification:
```php
public function via($notifiable)
{
return ['kingsms'];
}
public function toKingsms($notifiable)
{
return 'This is your notification message';
}
```
### 2. Your Notifiable Model must return the phone number
To let Laravel know which phone number to use, your notifiable model (usually User) must implement the following method:
```php
public function routeNotificationForKingsms(): ?string
{
// Example: clean Brazilian cellphone format and prepend +55
$phone = preg_replace('/\D/', '', $this->celular); // or $this->phone
return $phone ? '+55' . $phone : null;
}
```
Ensure your notifiable entity has a `phone` attribute or method.
---
## 🔗 Useful Links
- 📘 [Official KingSMS API Documentation](https://kingsms.docs.apiary.io/#)
- 🌐 [KingSMS Website](https://www.kingsms.com.br/)
---
## 👨💻 Author
Developed and maintained by:
**Anderson Arruda**
📧 [andmarruda@gmail.com](mailto:andmarruda@gmail.com)
Also maintained by:
**Sysborg**
📧 [contato@sysborg.com.br](mailto:contato@sysborg.com.br)