FreeSWITCH及VOIP,Openser,电话机器人等产品中文技术资讯、交流、沟通、培训、咨询、服务一体化网络。QQ群:293697898
微信公众号
由用户完成的,我们没有验证:
```
//https://github.com/Dreampie/Resty/blob/master/resty-example/src/test/java/cn/dreampie/example/HttpClientTest.java
//参考这个库
package cn.dreampie.example;
import cn.dreampie.client.HttpClientRequest;
import cn.dreampie.client.HttpClient;
import cn.dreampie.client.HttpClientResult;
import cn.dreampie.client.HttpClientUser;
import cn.dreampie.common.util.json.Jsoner;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.HashMap;
@FixMethodOrder(MethodSorters.JVM)
public class HttpClientTest {
private HttpClient httpClient;
public main(){
Client httpClient = new Client("http://ip:8085/api");
//post
ClientRequest postRequest = new ClientRequest("/login");
postRequest.setJsonParam("{\"username\": \"admin\", \"password\": \"admin\"}") ;
ClientResult postResult = httpClient.build(postRequest).post();
String json = postResult.getResult() ;
DemoToKen token = FasterJsonTool.readValue(json, DemoToKen.class) ;
System.out.println(token.getToken());
ClientRequest postRequest1 = new ClientRequest("/get_uuid");
Map<String, String> headers = new HashMap<>() ;
headers.put("Authorization", "Nway " + token.getToken()) ;
postRequest1.setHeaders(headers) ;
System.out.println(httpClient.build(postRequest1).get().getResult());
}
}
```