PHP code example of hosomikai / kotsms

1. Go to this page and download the library: Download hosomikai/kotsms library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hosomikai / kotsms example snippets


use Kotsms; 

...
    $content = 'hello world!';   //發送內容
    $smsNumber = '0911123456';   //發送對象手機號碼
    
    $costPoints = Kotsms::countAmount($content);    //試算此封簡訊會花費多少點數

    //發送簡訊
    $response = Kotsms::to($smsNumber)
                    ->content($content)
                    ->send();
    
    $response->isSuccess();     //是否成功
    $response->getMessage();    //回傳成功或錯誤訊息
    $response->toArray();