PHP code example of vicens / alidayu

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

    

vicens / alidayu example snippets


use Vicens\Alidayu\Alidayu;
Alidayu::setConfig([
   'appKey' => '23356838',
   'appSecret' => '254fee5fbabe2e01be04581d855c9af3',
   // 使用HTTPs
   'secure' => false,
   // 沙盒环境
   'sandbox' => false
]);

use Vicens\Alidayu\Alidayu;
// 发送短信通知
$sms = Alidayu::sms($recNum, $smsTemplateCode, $smsFreeSignName, $smsParam, $extend);
// 发送请求并返回响应
$response = $sms->send();

if ($response->success()) {
    // 接口返回成功
    print_r($response->getData());
} else {
    // 接口返回错误
    echo $response->getError();
}