PHP code example of minchao / every8d-php

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

    

minchao / every8d-php example snippets




nt = new \Every8d\Client(['username' => 'USERNAME', 'password' => 'PASSWORD']);

try {
    $sms = new \Every8d\Message\SMS('+886987654321', 'Hello, 世界');
    $result = $client->sendSMS($sms);
} catch (\Exception $e) {
    // 處理異常
}

[
    'Credit' => 79.0,
    'Sent' => 1,
    'Cost' => 1.0,
    'Unsent' => 0,
    'BatchID' => '00000000-0000-0000-0000-000000000000',
]

try {
    $batchId = '00000000-0000-0000-0000-000000000000';
    $result = $client->getDeliveryStatusBySMS($batchId);
} catch (\Exception $e) {
    // 處理異常
}

[
    'Count' => 1,
    'Records' => [
        'Name' => '',
        'Mobile' => '+886987654321',
        'SendTime' => '2018/01/01 00:00:00',
        'Cost' => 1.0,
        'Status' => 0,
    ],
]

try {
    $client->getCredit();
} catch (\Exception $e) {
    // 處理異常
}

79.0
console
$ php -S 127.0.0.1:80 -t webhook webhook/index.php
PHP 7.0.26 Development Server started at Mon Jan  1 12:00:00 2018
Listening on http://127.0.0.1:80
Document root is /srv/www/every8d-php/webhook
Press Ctrl-C to quit.

[Mon Jan  1 12:01:00 2018] http://your-webhook.com/callback?BatchID=00000000-0000-0000-0000-000000000000&RM=%2b886987654321&RT=20180101120002&STATUS=100&SM=Hello%2c+%e4%b8%96%e7%95%8c&CustID=CUSTID&UserNo=000000&ST=20180101120001&MR=1&SUBJECT=&NAME=NAME&USERID=USERNAME&SOURCE=&CHARGE=0
array:14 [
  "BatchID" => "00000000-0000-0000-0000-000000000000"
  "RM" => "+886987654321"
  "RT" => "20180101120002"
  "STATUS" => "100"
  "SM" => "Hello, 世界"
  "CustID" => "CUSTID"
  "UserNo" => "000000"
  "ST" => "20180101120001"
  "MR" => "1"
  "SUBJECT" => ""
  "NAME" => "NAME"
  "USERID" => "USERNAME"
  "SOURCE" => ""
  "CHARGE" => "0"
]