public static RetKit sendvercode(String phone,String code){
TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
req.setExtend("123456"); //回传参数
req.setSmsType("normal"); //短信类型
req.setSmsFreeSignName("魅格"); //短信签名,必须审核通过
req.setSmsParamString("{"number":"1234"}"); //短信模板变量,可传多个变量 必须审核通过的模版
req.setRecNum(phone); //短信接收号码
req.setSmsTemplateCode("SMS_58310033"); //短信模板ID
AlibabaAliqinFcSmsNumSendResponse rsp;
try {
rsp = client.execute(req);
System.out.println(rsp.getBody());
if(rsp.isSuccess()){
System.out.println("短信发送成功");
return RetKit.ok();
}else{
System.out.println("短信发送失败:"+rsp.getSubMsg());
return RetKit.fail(rsp.getSubMsg());
}
} catch (ApiException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
相关文档api地址
demo快速开始