PHP code example of aweitian / sms

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

    

aweitian / sms example snippets


$params = array(
    'SignName' => '十***理'
);

$helper = new SignatureHelper();

// 此处可能会抛出异常,注意catch
$content = $helper->request(
    'LTAI*****jnaqE',
    'SuO*********KVFgIxi',
    "dysmsapi.aliyuncs.com",
    array_merge($params, array(
        "RegionId" => "cn-hangzhou",
        "Action" => "QuerySmsSign",
        "Version" => "2017-05-25",
    )),
    true
);
var_dump($content);

$params = array(
    'TemplateCode' => 'SMS_226400252'
);

$helper = new SignatureHelper();

// 此处可能会抛出异常,注意catch
$content = $helper->request(
    'LT***naqE',
    'SuOU********VFgIxi',
    "dysmsapi.aliyuncs.com",
    array_merge($params, array(
        "RegionId" => "cn-hangzhou",
        "Action" => "QuerySmsTemplate",
        "Version" => "2017-05-25",
    )),
    true
);
var_dump($content);


$test = new \Aw\Sms\Ali\Send('LTA...YtG','UImf5*******aIm');
$test->setPhoneNumber("136........");
$test->setSignName("田AW");
$test->setTemplateCode("SMS_125015333");
$test->setTemplateParam(array (
  "code" => "102530",
));
$this->assertTrue($test->send());

$test = new \Aw\Sms\Ali\BatchSend('LTAIj*****tG','UImf5c0Pmw******WfdaIm',__DIR__."/sms.log");
$test->setPhoneNumber(array('136******','1*******29'));
$test->setSignName(array("田AW","田AW"));
$test->setTemplateCode("SMS_125015333");
$test->setTemplateParam(array(
    array(
        "code" => "123",
    ),
    array(
        "code" => "456",
    ),
));
$this->assertTrue($test->send());
var_dump($test->log);