PHP code example of xkeyi / aliyun-sms

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

    

xkeyi / aliyun-sms example snippets


use Xkeyi\AliyunSms\SendSms;

$config = [
    'access_key_id' => 'xxxxx',
    'access_key_secret' => 'xxxxx',
    'sign_name' => 'xxxxx', // 短信签名

];

$sms = new SendSms($config);

$result = $sms->send('18000000000', 'SMS_152549473', ['code' => '321475', 'name' => 'xxxx']);

    .
    .
    .
    'aliyun_sms' => [
        'access_key_id' => env('ALIYUN_SMS_ACCESS_KEY_ID'),
        'access_key_secret' => env('ALIYUN_SMS_ACCESS_KEY_SECRET'),
        'sign_name' => env('ALIYUN_SMS_SIGN_NAME'),
    ],

public function send(SendSms $sms)
{
    $res = $sms->send('18000000000', 'SMS_152549473', ['code' => '321475', 'name' => 'xxxx']);
}

public function send()
{
    $res = app('aliyun-sms')->send('18000000000', 'SMS_152549473', ['code' => '321475', 'name' => 'xxxx']);
}