PHP code example of davidxu / yii2-alisms
1. Go to this page and download the library: Download davidxu/yii2-alisms 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/ */
davidxu / yii2-alisms example snippets
php composer.phar
"php composer.phar update"
use davidxu\alisms\Sms;
class AliSms extends Controller
{
public function actionSend()
{
$alisms = new Sms();
$alisms->accessKeyId = 'your-alismsAccessKeyId';
$alisms->accessKeySecret = 'your-alismsAccessKeySecret';
$alisms->signName = 'your-smsSignName';
$mobiles = [
'18800000000',
'18800000002',
];
$response = $alisms->sendSms('your-template-code', $mobiles);
return $response;
}
public function actionQuery()
{
$alisms = new Sms();
$alisms->accessKeyId = Yii::$app->params['alismsAccessKeyId'];
$alisms->accessKeySecret = Yii::$app->params['alismsAccessKeySecret'];
$alisms->signName = Yii::$app->params['smsSignName'];
$mobile = '18800000001';
$queryDate = '20170720';
$response = $alisms->querySendDetails($mobile, $queryDate);
return $response;
}
}