del:del TestMail.java
This commit is contained in:
parent
ea129e94ab
commit
2647545ce8
|
@ -1,118 +0,0 @@
|
|||
package org.jeecg.modules.demo.test;
|
||||
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.http.Header;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSON;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class TestMail {
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
String headerURL = "https://api.qiye.163.com";
|
||||
String token = headerURL + "/api/pub/token/acquireToken";
|
||||
String getMailAccountInfo = headerURL + "/api/gw/qiye/mailaccount/getMailAccountInfo";
|
||||
String appId = "qy20231114144636B85B";
|
||||
String orgOpenId = "9c96b0ec1e6be89a";
|
||||
String authCode = "O1eSXJwU";
|
||||
|
||||
HashMap<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("appId", appId);
|
||||
paramMap.put("authCode", authCode);
|
||||
paramMap.put("orgOpenId", orgOpenId);
|
||||
|
||||
String tokenResult = reqHttpRequest(token, paramMap);
|
||||
JSONObject jsonObject = JSONUtil.parseObj(tokenResult);
|
||||
String code = jsonObject.get("code").toString();
|
||||
String accessTokenNew = jsonObject.get("accessToken").toString();
|
||||
System.out.println(tokenResult);
|
||||
|
||||
String accessToken = "a62a3904e56b49ec9fc3d310386880ae";
|
||||
// refreshToken = 57d0ddd2fc24499490717e48a1a786f7
|
||||
paramMap = new HashMap<>();
|
||||
paramMap.put("domain", "ndc.org.cn");
|
||||
paramMap.put("account_name", "cnndc.rn.ng");
|
||||
String result = reqHttpRequest(getMailAccountInfo, accessToken, appId, orgOpenId, paramMap);
|
||||
}
|
||||
|
||||
public static void reqHuTool(String reqURL, String appId, String orgOpenId, String authCode){
|
||||
HashMap<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("appId", appId);
|
||||
paramMap.put("authCode", authCode);
|
||||
paramMap.put("orgOpenId", orgOpenId);
|
||||
String reqToken = HttpUtil.post(reqURL, paramMap);
|
||||
System.out.println(reqToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取token
|
||||
* @param reqURL
|
||||
* @param paramMap
|
||||
* @return
|
||||
*/
|
||||
public static String reqHttpRequest(String reqURL, HashMap<String, Object> paramMap){
|
||||
|
||||
JSON parse = JSONUtil.parse(paramMap);
|
||||
|
||||
try {
|
||||
// String postData = buildPostDataString(paramMap);
|
||||
//链式构建请求
|
||||
String result2 = HttpRequest.post(reqURL)
|
||||
.header(Header.CONTENT_TYPE, "application/json")//头信息,多个头信息多次调用此方法即可
|
||||
// .form(paramMap)//表单内容
|
||||
.body(parse.toString())
|
||||
.timeout(20000)//超时,毫秒
|
||||
.execute().body();
|
||||
|
||||
Console.log(result2);
|
||||
return result2;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求接口,需要配置ip
|
||||
* @param reqURL
|
||||
* @param token
|
||||
* @param appId
|
||||
* @param orgOpenId
|
||||
* @param paramMap
|
||||
* @return
|
||||
*/
|
||||
public static String reqHttpRequest(String reqURL, String token, String appId, String orgOpenId, HashMap<String, Object> paramMap){
|
||||
|
||||
JSON parse = JSONUtil.parse(paramMap);
|
||||
|
||||
try {
|
||||
// String postData = buildPostDataString(paramMap);
|
||||
//链式构建请求
|
||||
String result2 = HttpRequest.post(reqURL)
|
||||
.header(Header.CONTENT_TYPE, "application/json")//头信息,多个头信息多次调用此方法即可
|
||||
.header("qiye-access-token", token)
|
||||
.header("qiye-app-id", appId)
|
||||
.header("qiye-org-open-id", orgOpenId)
|
||||
.header("qiye-timestamp", Long.toString(System.currentTimeMillis()))
|
||||
// .header("qiye-nonce", CodecUtils.hexEncode(CodecUtils.generateRandom(6)))
|
||||
// .form(paramMap)//表单内容
|
||||
.body(parse.toString())
|
||||
.timeout(20000)//超时,毫秒
|
||||
.execute().body();
|
||||
|
||||
Console.log(result2);
|
||||
return result2;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user