PHP code example of softbread / alidayu-php-sdk

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

    

softbread / alidayu-php-sdk example snippets


$sendSms = new Softbread\AlidayuSdk\AliSms;
$sendSms->setEnv(false); // use sandbox or not
$sendSms->setKey('api_key'); // set API key
$sendSms->setSecret('api_secret'); // set API secret
$sendSms->setSmsSign('sms_free_sign'); // set free sign in SMS content
$sendSms->setTemplateParams([
  'param1' => 'var1',
  'param2' => 'var2',
]); // set template params
$sendSms->setTemplate('template_id'); // set template ID
$sendSms->setSmsMobile('13000000000'); // set mobile number
$sendSms->send();

$sendSms = new Softbread\AlidayuSdk\AliSms([
    'env'    => false,
    'key'    => 'api_key',
    'secret' => 'api_secret',
]); // inject config as array

$sendSms->send(
    '13000000000',  // mobile number
    'sms_free_sign' , // free sign in SMS content
    'template_id',  // template ID
    [
      'param1' => 'var1',
      'param2' => 'var2',
    ]  // template params
);