hosomikai / kotsms
使用kotsms服务发送短信 - Laravel 5版本
1.1.1
2021-06-05 08:22 UTC
Requires
- php: ^7.0|^8.0
- illuminate/support: 5.*|^6.0|^7.0|^8.0
Requires (Dev)
- orchestra/testbench: ~3.6.7 || ~3.7.8 || ~3.8.6 || ^4.8 || ^5.2 || ^6.0
- phpunit/phpunit: 9.5.x-dev
This package is auto-updated.
Last update: 2024-09-05 15:26:15 UTC
README
laravel 5.6 - 8.x的要求
PHP >= 7
安装
通过Composer
1. 需求包
$ composer require hosomikai/kotsms
2. 设置.env环境变量
KOTSMS_USERNAME="your username"
KOTSMS_PASSWORD="your password"
如果你想加载demo示例 config/app.php
'providers' => [
...
Hosomikai\Kotsms\KotsmsDemoServiceProvider::class,
]
设置完成后浏览 https://:8000/test/kotsms
如果你要接收短信王发送短信后的结果
KOTSMS_RETURN_URL="your url for accepts kotsms request after send sms"
用法
1. 发送短信
use Kotsms;
...
$content = 'hello world!'; //發送內容
$smsNumber = '0911123456'; //發送對象手機號碼
$costPoints = Kotsms::countAmount($content); //試算此封簡訊會花費多少點數
//發送簡訊
$response = Kotsms::to($smsNumber)
->content($content)
->send();
$response->isSuccess(); //是否成功
$response->getMessage(); //回傳成功或錯誤訊息
$response->toArray();
toArray格式:
//成功
[
'value' => 'kmsgid',
'message' => '成功',
'success' => true,
];
//失敗
[
'value' => '-60002',
'message' => '您帳戶中的點數不足',
'success' => false,
];
2. 查询点数
use Kotsms;
...
//剩餘點數
$points = Kotsms::queryUserPoints();
3. 查询短信发送状态
use Kotsms;
...
$reposnse = Kotsms::queryStatus($kmsgid);
if ($response->isSuccess()) {
//成功
} else {
//失敗
}
变更日志
请参阅变更日志获取最近更改的更多信息。