generated from root/miduo_server
疯体ios登陆问题处理
parent
bf77f6a245
commit
aa06479719
|
|
@ -146,8 +146,6 @@ public class QuickVerifyService3 extends AbstractVerifyService {
|
|||
}
|
||||
|
||||
boolean doVerifyIos(VerifyParams params, String url) {
|
||||
LOGGER.info("疯体 Ohayoo 登录验证-->{}",params.getOpenId());
|
||||
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("app_id",params.getProductCode());
|
||||
map.put("token",params.getToken());
|
||||
|
|
@ -156,8 +154,9 @@ public class QuickVerifyService3 extends AbstractVerifyService {
|
|||
boolean result = false;
|
||||
String r = null;
|
||||
try {
|
||||
LOGGER.info("疯体 Ohayoo 登录验证-->{}",JSONObject.toJSONString(map));
|
||||
r = HttpUtils.doPost2(url, JSONObject.toJSONString(map));
|
||||
LOGGER.info("疯体 Ohayoo 请求结果:{}",r);
|
||||
LOGGER.info("疯体 Ohayoo 请求结果-->{}",r);
|
||||
JSONObject resultJson = JSON.parseObject(r);
|
||||
int status = resultJson.getIntValue("status");
|
||||
if(status == 0){
|
||||
|
|
|
|||
|
|
@ -41,43 +41,21 @@ public class HttpUtils {
|
|||
}
|
||||
|
||||
public static String doPost2(String url, String json) throws IOException {
|
||||
PrintWriter out = null;
|
||||
String result = "";
|
||||
CloseableHttpClient httpclient = HttpClients.createDefault();
|
||||
HttpPost httpPost = new HttpPost(url);
|
||||
StringEntity stringEntity = new StringEntity(json,ContentType.APPLICATION_FORM_URLENCODED);
|
||||
httpPost.setEntity(stringEntity);
|
||||
CloseableHttpResponse response2 = httpclient.execute(httpPost);
|
||||
|
||||
try {
|
||||
URL realUrl = new URL(url);
|
||||
// 打开和URL之间的连接
|
||||
URLConnection conn = realUrl.openConnection();
|
||||
// 设置通用的请求属性
|
||||
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
||||
// 发送POST请求必须设置如下两行
|
||||
conn.setDoOutput(true);
|
||||
conn.setDoInput(true);
|
||||
// 获取URLConnection对象对应的输出流
|
||||
out = new PrintWriter(conn.getOutputStream());
|
||||
// 发送请求参数
|
||||
out.print(json);
|
||||
// flush输出流的缓冲
|
||||
out.flush();
|
||||
// 获取请求返回的数据流
|
||||
InputStream is = conn.getInputStream();
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
// 封装输入流is,并指定字符集
|
||||
int i;
|
||||
while ((i = is.read()) != -1) {
|
||||
baos.write(i);
|
||||
}
|
||||
return baos.toString();
|
||||
} catch (Exception e) {
|
||||
System.out.println("发送 POST 请求出现异常!" + e);
|
||||
HttpEntity entity = response2.getEntity();
|
||||
return EntityUtils.toString(entity);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
} finally {
|
||||
response2.close();
|
||||
}
|
||||
// 使用finally块来关闭输出流、输入流
|
||||
finally {
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static List<NameValuePair> getFromMap(Map<String,String> parms){
|
||||
|
|
|
|||
Loading…
Reference in New Issue