function getrandchar($length){
$str = null;
$strPol = "0123456789abcdefghijklmnopqrstuvwxyz";
$max = strlen($strPol)-1;
for($i=0;$i<$length;$i++){
$str.=$strPol[rand(0,$max)];
}
return $str;
}
$code = getrandchar(5);
require_once(DEDEINC.'/aliyun-php-sdk-core/Config.php');
use Sms\Request\V20160927 as Sms;
$iClientProfile = DefaultProfile::getProfile("cn-shenzhen", "your accessKey", "your accessSecret"); //登录阿里云查看: "your accessKey", "your accessSecret"
$client = new DefaultAcsClient($iClientProfile);
$request = new Sms\SingleSendSmsRequest();
$request->setSignName("签名");/*签名名称*/
$request->setTemplateCode("SMS_1111");/*模板code*/
$request->setRecNum($phone);/*目标手机号*/
$request->setParamString("{\"code\":\"$code\",\"tel\":\"电话号码\"}");/*模板变量,请确保跟审核过的短信模版变量一致,数字一定要转换为字符串*/
try {
$response = $client->getAcsResponse($request);
print_r($response);
}
catch (ClientException $e) {
print_r($e->getErrorCode());
print_r($e->getErrorMessage());
}
catch (ServerException $e) {
print_r($e->getErrorCode());
print_r($e->getErrorMessage());
}
$inquery = " INSERT INTO `dede_phonecode` (`ip`,`phone`,`phonecode`,`used`,`sendtime`) VALUES ( '$ip','$to','$code','1','$nowtime'); ";
$rs = $dsql->ExecuteNoneQuery2($inquery);
if( $rs = 1 ){
ShowMsg('发送成功,请注意查收!','-1');
exit();
}
exit();
关键词标签: 织梦 阿里 短信
声明: 本文由我的SEOUC技术文章主页发布于:2023-07-18 ,文章织梦dedecms短信验证码功能(阿里短信),DEDE技术主要讲述短信,阿里,织梦网站建设源码以及服务器配置搭建相关技术文章。转载请保留链接: http://www.tngdez.cn/article/web_29185.html
为你推荐与织梦dedecms短信验证码功能(阿里短信),DEDE技术相关的文章
网站建设技术SEOUC.COM
专注网站建设,SEO优化,小程序设计制作搭建开发定制网站等,数千家网站定制开发案例,网站推广技术服务。
5000+合作客服
8年从业经验
150+覆盖行业
|