package mobvista.dmp.datasource.rtdmp;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
/**
* @author jiangfan
* @date 2021/3/29 17:59
*/
public class RtdmpNormal {
public static JSONObject doGetJson(String url) throws IOException {
JSONObject jsonObject = null;
// String url="http://portal-rtdmp.mintegral.com/rtdmp/audience/query?page=1&size=3&platform=2";
CloseableHttpClient client = HttpClients.createDefault();
HttpGet httpGet = new HttpGet(url);
String token = "52c1f9c84a4dbe6d6e08e668f134f23f";
httpGet.setHeader("key", "installapp");
httpGet.setHeader("token", token);
HttpResponse response = client.execute(httpGet);
HttpEntity entity = response.getEntity();
if (entity != null) {
String result = EntityUtils.toString(entity, "UTF-8");
jsonObject = JSON.parseObject(result);
}
return jsonObject;
}
}