分享按钮

阿里云短信

默认分类 / 2969人浏览 / 0人评论

//验证码发送
function sendmessage($mobile)
{
   $code=rand(1000,9999);
   include(ROOT_PATH."SmsDemo.php");
   // 调用示例:
   header('Content-Type: text/plain; charset=utf-8');
   $demo = new SmsDemo(
       "阿里云key",
       "阿里云secret"
   );
   $response = $demo->sendSms(
       "短信签名", // 短信签名
       "模板号", // 短信模板编号
       $mobile, // 短信接收者
       Array(  // 短信模板中字段的值
           "code"=>$code,

       ),
       ""
   );


cookie("code",$code,60*5);
cookie("phone",$mobile,60*5);
if($response->Code=='OK'){
   responseAjax(200,'短信发送成功');

}else{
   responseAjax(400,'请求失败');
}

}


感谢博主,喝杯咖啡~