zoukankan      html  css  js  c++  java
  • 第三方短信

    调用第三方短信验证

    首先进入阿里云去找到短信服务Api,然后在项目中调试,调试完成将他封装成模板类

    @Component
    public class SmsTest {
    
    	@Value("${sms.host}")
    	String host;
    	
    	@Value("${sms.path}")
    	String path ;
    	
    	@Value("${sms.method}")
    	String method;
    	
    	@Value("${sms.appcode}")
    	String appcode;
    	
    	public AppResponse<String> sendSms(Map<String , String> querys) {
    		Map<String, String> headers = new HashMap<String, String>();
    		
    		headers.put("Authorization", "APPCODE " + appcode);
    //		Map<String, String> querys = new HashMap<String, String>();
    //		querys.put("mobile", "19841822793");
    //		querys.put("param", "code:1234");
    //		querys.put("tpl_id", "TP1711063");
    		Map<String, String> bodys = new HashMap<String, String>();
    
    		try {
    
    			HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys);
    			System.out.println(response.toString());
    			return AppResponse.ok(response.toString());
    			
    		} catch (Exception e) {
    			e.printStackTrace();
    			return AppResponse.fail(null);
    		}
    	}
    }
    

    配置类中加入自动注入的信息

    sms.host=
    sms.path=
    sms.method=
    sms.appcode=
    

    自动注入

    @Autowired
    SmsTest smsTest;
    
  • 相关阅读:
    使用Scanner接受用户键盘输入的值
    使用 c3p0 连接数据库
    JDBC连接数据库
    SQL高级查询
    sql中的内连接和外连接
    存储过程的优缺点
    DML命令和DQL命令
    --sql语句创建表的同时添加外键约束
    JavaScript操作DOM对象(赠删表格中的元素)
    特效时钟
  • 原文地址:https://www.cnblogs.com/mankaixin/p/13860720.html
Copyright © 2011-2022 走看看