PHP code example of taiwan-sms / every8d

1. Go to this page and download the library: Download taiwan-sms/every8d 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/ */

    

taiwan-sms / every8d example snippets


// config/app.php
'providers' => [
    ...
    TaiwanSms\Every8d\Every8dServiceProvider::class,
],

// config/services.php
...
'every8d' => [
    'user_id'  => env('SERVICES_EVERY8D_USER_ID'),
    'password' => env('SERVICES_EVERY8D_PASSWORD'),
    'sms_host' => env('SERVICES_EVERY8D_SMS_HOST')
],
...

use TaiwanSms\Every8d\Every8dMessage;
use TaiwanSms\Every8d\Every8dChannel;
use Illuminate\Notifications\Notification;

class AccountApproved extends Notification
{
    public function via($notifiable)
    {
        return [Every8dChannel::class];
    }

    public function toEvery8d($notifiable)
    {
        return Every8dMessage::create("Task #{$notifiable->id} is complete!");
    }
}

public function routeNotificationForEvery8d()
{
    return $this->phone;
}



use TaiwanSms\Every8d\Client;

$userId = 'xxx';
$password = 'xxx';

$client = new Client(userId, $password);

$client->credit(); // 取得額度
var_dump($client->send([
    'to' => '09xxxxxxxx',
    'text' => 'test message',
]));
/*
return [
    'credit' => 100.0,
    'sended' => 1,
    'cost' => 1.0,
    'unsend' => 0,
    'batchId' => 'd0ad6380-4842-46a5-a1eb-9888e78fefd8',
];
 */
bash
composer 
bash
composer