Commit 4c47577d by 王召彬

添加发送短信公共类 Alisms.php

parent 716b080d
......@@ -7,5 +7,9 @@ return [
'SecretId' => 'AKIDseHj18kua0KTSJ4g9SadbVEnEUZVjvPj',
'SecretKey' => 'IPL5g5PaaSAzd6NSO8gEmLxcN4pTzJSQ',
'Region' => 'ap-shanghai'
],
'alisms' => [
'accessKeyId' => 'EjBn9zQxyEkKHyAA',
'accessKeySecret' => 'AN276rwCcqCkFUVt1GLCbAy8jnj52t',
]
];
\ No newline at end of file
<?php
namespace Hdll\Services\Common\Lib;
use Flc\Dysms\Client;
use Flc\Dysms\Request\SendSms;
class Alisms
{
protected $config;
protected $templateCode;
protected $templateParam;
protected $signName;
public function __construct($signName, $templateCode, $templateParam)
{
// 短信签名,示例:活动啦啦
$this->signName = $signName;
// 短信模板编号
$this->templateCode = $templateCode;
// 短信模板预设参数
$this->templateParam = $templateParam;
$configurator = \Swoft\App::getBean('config');
$configurator->load('@vendor/hdll/services/src/Common/Config');
$this->config = $configurator->get('alisms');
}
/**
* 发送短信(发送预设置的短信模板)
* @param $phone
* @return mixed
*/
public function send($phone)
{
$client = new Client($this->config);
$sendSms = new SendSms();
$sendSms->setPhoneNumbers($phone);
$sendSms->setSignName($this->signName);
$sendSms->setTemplateCode($this->templateCode);
$sendSms->setTemplateParam($this->templateParam);
$sendSms->setOutId('hdll');
return $client->execute($sendSms);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment