【PHP|php发送短信】1.调用alidayu的工具类包,然后配置参数
public function sendSMS ($mobile, $content,$type,$pcode,$address)
{
include("TopSdk.php");
date_default_timezone_set('Asia/Shanghai');
$c = new \TopClient();
switch ($type){
case '1':
$c->appkey = "*****";
$c->secretKey = "************";
//$req = new AlibabaAliqinFcSmsNumSendRequest;
$req = new \AlibabaAliqinFcSmsNumSendRequest();
$req->setSmsType("normal");
$req->setSmsFreeSignName("好运生活");
$req->setSmsParam("{\"village\":\"".$content."\",\"pcode\":\"".$pcode."\",\"address\":\"".$address."\"}");
$req->setRecNum($mobile);
$req->setSmsTemplateCode("SMS_127161604");
$resp = $c->execute($req);
break;
default :
$c->appkey = "*****";
$c->secretKey = "**********";
//$req = new AlibabaAliqinFcSmsNumSendRequest;
$req = new \AlibabaAliqinFcSmsNumSendRequest();
$req->setSmsType("normal");
$req->setSmsFreeSignName("顺手拿");
$req->setSmsParam("{\"code\":\"".$content."\",\"product\":\"shunshouna\"}");
$req->setRecNum($mobile);
$req->setSmsTemplateCode("SMS_33580526");
$resp = $c->execute($req);
break;
}
if($resp->result->success){
return true;
}
else{
return false;
}
}
2.调用sendSMS方法.并进行处理.
$res = (new Aliyun())->sendSMS($this->_param['mobile'],$this->_param['village'],1,$this->_param['p_code'],$this->_param['address']);
推荐阅读
- 对GO切片的理解
- 小程序商城网站开发秒杀模块篇
- 盲盒购物网站系统开发建设 第三篇
- Netty核心概念之ChannelHandler&Pipeline&ChannelHandlerContext
- 简单的线程池实现多线程对大文件的读取
- SSH 端口转发与 SOCKS 代理
- Ubuntu16.04/Scala2.11.8安装教程
- 学习PHP中的高精度计时器HRTime扩展
- 使用OpenResty+Lua实现灰度测试(金丝雀)
- 使用源码编译安装PHP扩展