|
|
|
@ -1,6 +1,7 @@ |
|
|
|
package cn.chjyj.szwh.utils; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.commons.logging.Log; |
|
|
|
import org.apache.commons.logging.LogFactory; |
|
|
|
import org.apache.http.StatusLine; |
|
|
|
@ -24,17 +25,22 @@ public class RequestUtils { |
|
|
|
private static Log logger = LogFactory.getLog(RequestUtils.class); |
|
|
|
/** |
|
|
|
* 利用GET方式获取uri数据 |
|
|
|
* @param wxuri |
|
|
|
* @param requri 请求地址 |
|
|
|
* @param token 访问凭据 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public static JSONObject doGetUrlData(String wxuri){ |
|
|
|
public static JSONObject doGetUrlData(String requri,String token){ |
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
try { |
|
|
|
URL url = new URL(wxuri); |
|
|
|
URL url = new URL(requri); |
|
|
|
HttpURLConnection httpcon = (HttpURLConnection) url.openConnection(); |
|
|
|
httpcon.setRequestMethod("GET"); |
|
|
|
httpcon.setDoOutput(true); |
|
|
|
httpcon.setDoInput(true); |
|
|
|
// 存在token的时候
|
|
|
|
if(StringUtils.isNotEmpty(token)){ |
|
|
|
httpcon.setRequestProperty("api_token",token); |
|
|
|
} |
|
|
|
httpcon.connect(); |
|
|
|
//获取返回的字符
|
|
|
|
InputStream inputStream = httpcon.getInputStream(); |
|
|
|
|