Via Composer
$ composer require hosomikai/kotsms
KOTSMS_USERNAME="your username"
KOTSMS_PASSWORD="your password"
如果你想載入demo範例 config/app.php
'providers' => [
...
Hosomikai\Kotsms\KotsmsDemoServiceProvider::class,
]
設定完成後瀏覽 http://localhost:8000/test/kotsms
如果你要接收簡訊王發送簡訊後的結果
KOTSMS_RETURN_URL="your url for accepts kotsms request after send sms"
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,
];
use Kotsms;
...
//剩餘點數
$points = Kotsms::queryUserPoints();
use Kotsms;
...
$reposnse = Kotsms::queryStatus($kmsgid);
if ($response->isSuccess()) {
//成功
} else {
//失敗
}
Please see the changelog for more information on what has changed recently.