手机发送验证码

1、声明AliPhoneCode类传入KEYID accessKeyid ,密钥accessKeyserver, 签名 signName, 模板代码 templateCode(当传值为空或null时默认使用框架中自带模板信息);

2、调用获取验证码方法getPhoneCode传入phone电话号码即可发验证码送消息到对应的手机号且返回这个发送的验证码以供后续使用。

package dynamic.auto;

import microbee.http.annotation.ExcludeL;
import microbee.http.annotation.ModelResources;
import microbee.http.apps.dynamic.HoContext;
import microbee.http.annotation.Controller;
import java.util.Map;
import java.util.HashMap;
import org.apache.commons.lang.StringUtils;
import dynamic.model.Sm_Md213;
import com.alibaba.fastjson.JSONObject;
import dynamic.utills.AliPhoneCode;

@Controller
public class Au_PohneCode {
    
    @ModelResources  
    Sm_Md213 sm_md213;
    @ExcludeL
    public String handlerBF(HoContext var1) {
        Map<String, String> params = var1.httpRequest.getParams();
        Map<String,Object> res = new HashMap<>();
        res.put("code",500);
        res.put("msg","发送失败!");
        AliPhoneCode aliPhoneCode = new AliPhoneCode("","","","");
        String code = aliPhoneCode.getPhoneCode(params.get("phone"));
        if(StringUtils.isNotEmpty(code)){
            res.put("code",200);
            res.put("msg","发送成功!");
            var1.httpRequest.setSession("phoneCode",code);
        }
        return JSONObject.toJSONString(res);
    }
}

 

本文档来自—microbee-http 丨 软件开发框架平台