|
@@ -0,0 +1,78 @@
|
|
|
+package org.springblade.archive.utils;
|
|
|
+
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
+import org.apache.http.Consts;
|
|
|
+import org.apache.http.HttpEntity;
|
|
|
+import org.apache.http.HttpResponse;
|
|
|
+import org.apache.http.client.config.RequestConfig;
|
|
|
+import org.apache.http.client.entity.UrlEncodedFormEntity;
|
|
|
+import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
+import org.apache.http.client.methods.HttpGet;
|
|
|
+import org.apache.http.client.methods.HttpPost;
|
|
|
+import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
+import org.apache.http.impl.client.HttpClients;
|
|
|
+import org.apache.http.message.BasicNameValuePair;
|
|
|
+import org.apache.http.util.EntityUtils;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+public class CallBgrsjk {
|
|
|
+ //模型预览,post请求获取BIMFACE服务器端API接口 获取Access Token
|
|
|
+ public static String callpostdata(String requestParams) {
|
|
|
+ String url = null;
|
|
|
+ JSONObject jb=new JSONObject();
|
|
|
+ jb.put("code",0);
|
|
|
+ try {
|
|
|
+ CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
|
+ RequestConfig requestConfig = RequestConfig.custom()
|
|
|
+ .setSocketTimeout(300 * 1000)
|
|
|
+ .setConnectTimeout(300 * 1000)
|
|
|
+ .build();
|
|
|
+// url = "http://URL:Port/地址";
|
|
|
+ url = "https://api.bimface.com/oauth2/token";
|
|
|
+ HttpPost post = new HttpPost(url);
|
|
|
+ post.setConfig(requestConfig);
|
|
|
+ post.setHeader("Authorization",requestParams);
|
|
|
+// StringEntity postingString = new StringEntity(requestParams,
|
|
|
+// "utf-8");
|
|
|
+// post.setEntity(postingString);
|
|
|
+ HttpResponse response = httpClient.execute(post);
|
|
|
+ String content = EntityUtils.toString(response.getEntity());
|
|
|
+ System.out.println(content);
|
|
|
+ return content;
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ return jb.toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //模型预览,get请求获取BIMFACE服务器端API接口 获取模型的View Token
|
|
|
+ public static String callgetdata(String requestParams, List<BasicNameValuePair> list) {
|
|
|
+ String url = null;
|
|
|
+ JSONObject jb=new JSONObject();
|
|
|
+ jb.put("code",0);
|
|
|
+ try {
|
|
|
+
|
|
|
+// 1、创建httpClient
|
|
|
+ CloseableHttpClient client = HttpClients.createDefault();
|
|
|
+// 2、封装请求参数
|
|
|
+// List<BasicNameValuePair> list = new ArrayList<BasicNameValuePair>();
|
|
|
+// list.add(new BasicNameValuePair("fileId", "2016629174421504"));
|
|
|
+
|
|
|
+ //3、转化参数
|
|
|
+ String params = EntityUtils.toString(new UrlEncodedFormEntity(list, Consts.UTF_8));
|
|
|
+ //4、创建HttpGet请求
|
|
|
+ HttpGet httpGet = new HttpGet("https://api.bimface.com/view/token"+"?"+params);
|
|
|
+ httpGet.setHeader("Authorization",requestParams);
|
|
|
+ CloseableHttpResponse response = client.execute(httpGet);
|
|
|
+
|
|
|
+ //5、获取实体
|
|
|
+ HttpEntity entity = response.getEntity();
|
|
|
+ //将实体装成字符串
|
|
|
+ String string = EntityUtils.toString(entity);
|
|
|
+ return string;
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ return jb.toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|