安裝套件
$ composer require hosomikai/kotsms
安裝完套件之後我們必須設定 .env
KOTSMS_USERNAME="你的簡訊王帳號"
KOTSMS_PASSWORD="你的簡訊王密碼"
這樣我們的設定就完成了。
發送簡訊
use Hosomikai\Kotsms\Facade\Kotsms;...$smsNumber = '接收簡訊的手機號碼';
$content = '你要發送的簡訊內容';$response = Kotsms::to($smsNumber)
->content($content)
->send();
這樣就可以發送簡訊了。
如果你想要確認api回傳的結果:
if ($response->isSuccess()) { //成功} else { $message = $this->getMessage(); //失敗訊息}
查詢剩餘點數
use Hosomikai\Kotsms\Facade\Kotsms;...$points = Kotsms::queryUserPoints(); //你的剩餘點數