Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
services
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tencent
services
Commits
3927d121
Commit
3927d121
authored
Jul 25, 2018
by
王召彬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化阿里云短信发送类
parent
4c47577d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
3 deletions
+39
-3
src/Common/Lib/Alisms.php
+39
-3
No files found.
src/Common/Lib/Alisms.php
View file @
3927d121
...
...
@@ -4,18 +4,38 @@ namespace Hdll\Services\Common\Lib;
use
Flc\Dysms\Client
;
use
Flc\Dysms\Request\SendSms
;
/**
* 阿里云发送短信工具类
* 使用:
* $alisms = new Alisms(Alisms::SN_01,'SMS_101145139',['code' => $vcode]);
* 或:
* $alisms = (new Alisms)->setSignName(Alisms::SN_01)
* ->setTemplateCode(Alisms::TPL_01)
* ->setTemplateParam(['code' => $vcode]);
* $response = $alisms->send(15825290203);
*/
class
Alisms
{
// 阿里云注册的签名列表:
// 目前只有一个
const
SN_01
=
'活动啦啦'
;
// 签名1
// 阿里云注册的短信模板列表:
// 目前只有一个
const
TPL_01
=
'SMS_101145139'
;
// 模板1
protected
$config
;
protected
$templateCode
;
protected
$templateParam
;
protected
$signName
;
public
function
__construct
(
$signName
,
$templateCode
,
$templateParam
)
public
function
__construct
(
$signName
=
null
,
$templateCode
=
null
,
$templateParam
=
[])
{
// 短信签名,示例:活动啦啦
$this
->
signName
=
$signName
;
$this
->
signName
=
$signName
??
self
::
SN_01
;
// 短信模板编号
$this
->
templateCode
=
$templateCode
;
$this
->
templateCode
=
$templateCode
??
self
::
TPL_01
;
// 短信模板预设参数
$this
->
templateParam
=
$templateParam
;
...
...
@@ -44,5 +64,20 @@ class Alisms
}
public
function
setSignName
(
$signName
){
$this
->
signName
=
$signName
;
return
$this
;
}
public
function
setTemplateCode
(
$templateCode
){
$this
->
templateCode
=
$templateCode
;
return
$this
;
}
public
function
setTemplateParam
(
$templateParam
){
$this
->
templateParam
=
$templateParam
;
return
$this
;
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment