cn.fangxinqian.operator.sdk.utils.OkHttp Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sdk-operator Show documentation
Show all versions of sdk-operator Show documentation
identity contract sign smssend file convert
package cn.fangxinqian.operator.sdk.utils;
import okhttp3.*;
import java.io.IOException;
/**
* @Author NieZhiLiang
* @Email [email protected]
* @GitHub https://github.com/niezhiliang
* @Date 2019-10-09 9:11 上午
*/
public class OkHttp {
/**
* 使用okhttp请求
* @param url 请求地址
* @param json 请求的json数据
* @return
* @throws IOException
*/
public static String doPost(String url, String json) throws IOException {
OkHttpClient client = new OkHttpClient();
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"),json);
Request request = new Request.Builder()
.url(url)
.post(body)
.build();
try (Response response = client.newCall(request).execute()) {
return response.body().string();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy