Pu Zhibing
6 天以前 4c99ee7028c3fe58a2cd4b8273b22c75c45574fc
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
//package com.stylefeng.guns.modular.system.util;
//
//import com.alibaba.fastjson.JSONObject;
//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;
//import com.stylefeng.guns.core.util.MD5Util;
//import org.apache.commons.codec.binary.Base64;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//import java.io.IOException;
//import java.util.HashMap;
//import java.util.Map;
//
///**
// * 中国移动工具类
// */
//@Component
//public class ChinaMobileUtil {
//
//    private static String APIKey = "LTAI4G1BpRaihVRZp1RS8Stn";
//
//    private static String SecretKey = "PDR7uUEGNf0wIPPVCPCVdySgTwCr90";
//
//    @Autowired
//    private HttpClientUtil httpClientUtil;
//
//
//    /**
//     * 绑定小号
//     * @param phoneA
//     * @param phoneB
//     * @param areaCode
//     * @return
//     * @throws Exception
//     */
//    public static Map<String, String> midAxbBindSend(String phoneA, String phoneB, Integer areaCode) throws Exception{
//        Map<String, String> map1 = new HashMap<>();
//        map1.put("code", "-1");
//        map1.put("msg", "");
//        map1.put("telX", "");
//        map1.put("bindId", "");
//        return map1;
//        //暂时屏蔽-后期放开
//        /*DefaultProfile profile = DefaultProfile.getProfile(
//                "cn-hangzhou",            // 地域ID
//                APIKey,        // 您的AccessKey ID
//                SecretKey );  // 您的AccessKey Secret
//        IAcsClient client = new DefaultAcsClient(profile);
//
//        CommonRequest request = new CommonRequest();
//        request.setMethod(MethodType.POST);
//        request.setDomain("dyplsapi.aliyuncs.com");
//        request.setVersion("2017-05-25");
//        request.setAction("BindAxb");
//        // 绑定关系的过期时间。必须晚于当前时间1分钟以上。
//        request.putQueryParameter("Expiration", DateUtil.format(new Date(new Date().getTime()+7 * 24 * 60 * 60*1000L),"yyyy-MM-dd HH:mm:ss"));
//        // 号码池Key
//        request.putQueryParameter("PoolKey", "FC100000119206151");
//        // AXB中的B号码
//        request.putQueryParameter("PhoneNoB", phoneB);
//        // AXB中的A号码
//        request.putQueryParameter("PhoneNoA", phoneA);
//        // 指定城市进行X号码的选号。
//        request.putQueryParameter("ExpectCity", "北京");
//        // 是否需要针对该绑定关系产生的所有通话录制通话录音。
//        request.putQueryParameter("IsRecordingEnabled", "false");
//        Map<String, String> map1 = new HashMap<>();
//        try {
//            CommonResponse response = client.getCommonResponse(request);
//            // 处理请求结果
//            System.out.println(response.getData());
//            JSONObject jsonObject = JSONObject.parseObject(response.getData());
//            if(jsonObject.getString("Code").equals("OK")){
//                map1.put("code", "200");
//                map1.put("msg", jsonObject.getString("Message"));
//                map1.put("telX", jsonObject.getJSONObject("SecretBindDTO").getString("SecretNo"));
//                map1.put("bindId", jsonObject.getJSONObject("SecretBindDTO").getString("SubsId"));
//            }else{
//                map1.put("code", jsonObject.getString("Code"));
//                map1.put("msg", jsonObject.getString("Message"));
//            }
//        } catch (ServerException e) {
//            e.printStackTrace();
//            map1.put("code", "-1");
//            map1.put("msg", e.getErrMsg());
//        } catch (ClientException e) {
//            System.out.println("ErrCode:" + e.getErrCode());
//            System.out.println("ErrMsg:" + e.getErrMsg());
//            System.out.println("RequestId:" + e.getRequestId());
//            map1.put("code", "-1");
//            map1.put("msg", e.getErrMsg());
//        }
//        return map1;*/
//    }
//
//
//    /**
//     * 解绑小号关系
//     * @param bindId    绑定关系id
//     * @return
//     * @throws Exception
//     */
//    public static Map<String, String> midAxbUnBindSend(String bindId,String secretNo) throws Exception{
//        DefaultProfile profile = DefaultProfile.getProfile(
//                "cn-hangzhou",            // 地域ID
//                APIKey,        // 您的AccessKey ID
//                SecretKey );  // 您的AccessKey Secret
//        IAcsClient client = new DefaultAcsClient(profile);
//
//        CommonRequest request = new CommonRequest();
//        request.setMethod(MethodType.POST);
//        request.setDomain("dyplsapi.aliyuncs.com");
//        request.setVersion("2017-05-25");
//        request.setAction("UnbindSubscription");
//        // 绑定关系的过期时间。必须晚于当前时间1分钟以上。
//        // 号码池Key
//        request.putQueryParameter("PoolKey", "FC100000119206151");
//        // 隐私号码。调用BindAXG等号码绑定接口时指定或自动分配的X号码。
//        request.putQueryParameter("SecretNo", secretNo);
//        // 绑定关系ID。
//        //
//        //可以在控制台的号码管理 > 号码详情中查看绑定关系ID,或者在调用BindAxb等号码绑定API时查看返回参数中的SubsId。
//        request.putQueryParameter("SubsId", bindId);
//        Map<String, String> map1 = new HashMap<>();
//        try {
//            CommonResponse response = client.getCommonResponse(request);
//            // 处理请求结果
//            System.out.println(response.getData());
//            JSONObject jsonObject = JSONObject.parseObject(response.getData());
//            if(jsonObject.getString("Code").equals("OK")){
//                map1.put("code", "200");
//                map1.put("msg", jsonObject.getString("Message"));
//            }else{
//                map1.put("code", jsonObject.getString("Code"));
//                map1.put("msg", jsonObject.getString("Message"));
//            }
//        } catch (ServerException e) {
//            e.printStackTrace();
//            map1.put("code", "-1");
//            map1.put("msg", e.getErrMsg());
//        } catch (ClientException e) {
//            System.out.println("ErrCode:" + e.getErrCode());
//            System.out.println("ErrMsg:" + e.getErrMsg());
//            System.out.println("RequestId:" + e.getRequestId());
//            map1.put("code", "-1");
//            map1.put("msg", e.getErrMsg());
//        }
//        return map1;
//    }
//
//    public static  void main(String[] args) throws IOException {
//        try{
//            // System.out.println(midAxbBindSend("18380476116","13688394165",null));
//         System.out.println(midAxbUnBindSend("1000031640138366","17150145472"));
//        }catch (Exception e){
//
//        }
//
//    }
//
//
//    public Map<String, String> HeaderUtils(String APIKey, String SecretKey) throws Exception{
//        Map<String, String> header = new HashMap<>();
//        long time = System.currentTimeMillis();
//        String signStr = MD5Util.encrypt(APIKey + SecretKey + time);
//        JSONObject jsonObject = new JSONObject();
//        jsonObject.put("apiKey", APIKey);
//        jsonObject.put("time", time);
//        jsonObject.put("sign", signStr);
//        Base64 base64 = new Base64();
//        String s = base64.encodeToString(jsonObject.toJSONString().getBytes("UTF-8"));
//        header.put("header", s);
//
//        jsonObject = new JSONObject();
//        jsonObject.put("platformId", "");
//        jsonObject.put("secret", "");
//        s = base64.encodeToString(jsonObject.toJSONString().getBytes("UTF-8"));
//        header.put("accessCode", s);
//        return header;
//    }
//}