手机找回密码,阿里实现纯java


阿里实现手机找回密码纯java

package com.e.demo;

import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;

public class T {

**依赖**
pom.xml
   
  com.aliyun
  aliyun-java-sdk-core
  4.0.3


//手机demo


        public static void main(String[] args) {
        DefaultProfile profile = DefaultProfile.getProfile("cn-shenzhen", "", "");
        IAcsClient client = new DefaultAcsClient(profile);

        CommonRequest request = new CommonRequest();
        request.setMethod(MethodType.POST);
        request.setDomain("dysmsapi.aliyuncs.com");
        request.setVersion("2017-05-25");
        request.setAction("SendSms");
        request.putQueryParameter("RegionId", "cn-shenzhen");
        request.putQueryParameter("PhoneNumbers", "自己手机号");
        request.putQueryParameter("SignName", "签名");  //在阿里云的短信服务里面找,没有的话需要申请
        request.putQueryParameter("TemplateCode", "模板");//在阿里云的短信服务里面找,没有的话需要申请
        request.putQueryParameter("TemplateParam", "{\"code\":\"123\"}");//验证码
        try {
            CommonResponse response = client.getCommonResponse(request);
            System.out.println(response.getData());
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            e.printStackTrace();
        }
    }
}

你可能感兴趣的:(java)