1. Go to this page and download the library: Download yii2vn/esms 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/ */
$phone = '0909113911';
$esms = Yii::$app->eSMS;
if ($esms->sendSMS($phone, 'Xin chao')) {
Yii::$app->session->setFlash('Success!');
} else {
Yii::warning('Không thể gửi tin đến sđt: ' . $phone . ' Lỗi: ' . $esms->error);
}
$phones = ['0909113911', '0909911113', '0909123456'];
$esms = Yii::$app->eSMS;
if ($esms->batchSendSMS($phones, 'Xin chao')) {
Yii::$app->session->setFlash('Success!');
} else {
Yii::warning('Không thể gửi tin đến sđt: ' . $phone . ' Lỗi: ' . $esms->error);
}
$phones = [
'0909113911' => 'Ngay mai hop luc 8h',
'0909911113' => 'Thu 2 lam ca sang',
'0909123456' => '01/05 duoc nghi lam'
];
$esms = Yii::$app->eSMS;
if ($esms->batchSendSMS($phones)) {
Yii::$app->session->setFlash('Success!');
} else {
Yii::warning('Không thể gửi tin đến sđt: ' . $phone . ' Lỗi: ' . $esms->error);
}
$phones = [
'0909113911' => 'Ngay mai nhan vien se hop luc 8h! Kinh moi sep tham gia cuoc hop', // Số của sếp
'0909911113', '0909123321', '0909963147'
];
$esms = Yii::$app->eSMS;
if ($esms->batchSendSMS($phones, 'Ngay mai moi nguoi du hop vao luc 8h! Co sep den du.')) {
Yii::$app->session->setFlash('Success!');
} else {
Yii::warning('Không thể gửi tin đến sđt: ' . $phone . ' Lỗi: ' . $esms->error);
}
$phone = '0909113911';
$apiCode = '58888'; // lấy trên hệ thống ESMS để xác định mẫu cuộc gọi thoại
$passCode = '12345'; // lấy trên hệ thống ESMS để xác định mẫu cuộc gọi thoại
$esms = Yii::$app->eSMS;
if ($esms->sendVoiceCall($phone, $apiCode, $passCode, 'Xin chao')) {
Yii::$app->session->setFlash('Success!');
} else {
Yii::warning('Không thể gửi tin đến sđt: ' . $phone . ' Lỗi: ' . $esms->error);
}
$phones = ['0909113911', '0909911113', '0909123456'];
$apiCode = '58888'; // lấy trên hệ thống ESMS để xác định mẫu cuộc gọi thoại
$passCode = '12345'; // lấy trên hệ thống ESMS để xác định mẫu cuộc gọi thoại
$esms = Yii::$app->eSMS;
if ($esms->batchSendVoiceCall($phones, $apiCode, $passCode, 'Xin chao')) {
Yii::$app->session->setFlash('Success!');
} else {
Yii::warning('Không thể gửi tin đến sđt: ' . $phone . ' Lỗi: ' . $esms->error);
}
$phones = [
'0909113911' => 'Ngay mai hop luc 8h',
'0909911113' => 'Thu 2 lam ca sang',
'0909123456' => '01/05 duoc nghi lam'
];
$apiCode = '58888'; // lấy trên hệ thống ESMS để xác định mẫu cuộc gọi thoại
$passCode = '12345'; // lấy trên hệ thống ESMS để xác định mẫu cuộc gọi thoại
$esms = Yii::$app->eSMS;
if ($esms->batchSendVoiceCall($phones, $apiCode, $passCode)) {
Yii::$app->session->setFlash('Success!');
} else {
Yii::warning('Không thể gửi tin đến sđt: ' . $phone . ' Lỗi: ' . $esms->error);
}
$phones = [
'0909113911' => 'Ngay mai nhan vien se hop luc 8h! Kinh moi sep tham gia cuoc hop', // Số của sếp
'0909911113', '0909123321', '0909963147'
];
$apiCode = '58888'; // lấy trên hệ thống ESMS để xác định mẫu cuộc gọi thoại
$passCode = '12345'; // lấy trên hệ thống ESMS để xác định mẫu cuộc gọi thoại
$esms = Yii::$app->eSMS;
if ($esms->batchSendVoiceCall($phones, $apiCode, $passCode, 'Ngay mai moi nguoi du hop vao luc 8h! Co sep den du.')) {
Yii::$app->session->setFlash('Success!');
} else {
Yii::warning('Không thể gửi tin đến sđt: ' . $phone . ' Lỗi: ' . $esms->error);
}
$esms = Yii::$app->eSMS;
var_dump($esms->getBalance());
// Kết quả:
// array(3) { ["Balance"]=> int(2293566) ["CodeResponse"]=> string(3) "100" ["UserID"]=> int(999999999999) }
$esms->sendSMS("0909113911", "hello");
var_dump($esms->getBalance());
// Kết quả số dư vẫn như cữ:
// array(3) { ["Balance"]=> int(2293566) ["CodeResponse"]=> string(3) "100" ["UserID"]=> int(999999999999) }
var_dump($esms->getBalance(true)); // kết quả sẽ thay đổi vì chúng ta lấy lại dữ liệu sau khi gửi tin => số tiền sẽ giảm
php composer.phar
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.