中国算力平台算力登记系统2.0
yanzhaofeige
2024-09-30 3c4fee1db116c11d4f04727cfe076d7c94daeaf2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package com.odcc.cpzidc.common.utils.sms;
 
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.mzlion.easyokhttp.HttpClient;
 
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
 
public class SMSYUnPian {
 
 
    /**
     * 用户登记验证码
     * @param mobile
     * @param code
     * @param language
     * @return
     * @throws UnsupportedEncodingException
     */
    public static Integer sendVerificationCode(String mobile,String code,String language) throws UnsupportedEncodingException {
        String tpl_id = "5921370";
        if(language.equals("zh")){
            tpl_id = "5921370";
        }else if(language.equals("en")){
            tpl_id = "5921464";
        }else if(language.equals("ru")){
            tpl_id = "5921466";
        }
        Map<String, String> params = new HashMap<String, String>();
        params.put("apikey", "c92bf9680de6e2df1644bb517815c4a6");
        params.put("mobile", mobile);
        params.put("tpl_id", tpl_id);
        params.put("tpl_value", URLEncoder.encode("#code#", "utf-8") + "=" + URLEncoder.encode(code, "utf-8") );
        String responseData = HttpClient
                // 请求方式和请求url
                .post("https://sms.yunpian.com/v2/sms/tpl_single_send.json")
                // 表单参数
                .param(params)
                //url参数
                .asString();
        JSONObject jsonObject = JSON.parseObject(responseData);
        System.out.println(responseData);
        return jsonObject.getInteger("code");
    }
 
 
    /**
     * 用户登记验证码
     * @param mobile
     * @param name
     * @param language
     * @return
     * @throws UnsupportedEncodingException
     */
    public static Integer sendRegSuccess(String mobile,String name,String language) throws UnsupportedEncodingException {
        String tpl_id = "5921300";
        if(language.equals("zh")){
            tpl_id = "5921300";
        }else if(language.equals("en")){
            tpl_id = "5921302";
        }else if(language.equals("ru")){
            tpl_id = "5921466";
        }
        Map<String, String> params = new HashMap<String, String>();
        params.put("apikey", "c92bf9680de6e2df1644bb517815c4a6");
        params.put("mobile", mobile);
        params.put("tpl_id", tpl_id);
        params.put("tpl_value", URLEncoder.encode("#name#", "utf-8") + "=" + URLEncoder.encode(name, "utf-8") );
        String responseData = HttpClient
                // 请求方式和请求url
                .post("https://sms.yunpian.com/v2/sms/tpl_single_send.json")
                // 表单参数
                .param(params)
                //url参数
                .asString();
        JSONObject jsonObject = JSON.parseObject(responseData);
        return jsonObject.getInteger("code");
    }
 
    public static void main(String args[]) throws UnsupportedEncodingException {
        System.out.println(sendVerificationCode("18612580880","38383","zh"));
      //  System.out.println(sendRegSuccess("18612580880","38383","zh"));
    }
 
 
}