generated from root/miduo_server
疯体ios登陆修改4
parent
178af21e33
commit
318556bc28
|
|
@ -148,26 +148,24 @@ public class QuickVerifyService3 extends AbstractVerifyService {
|
|||
boolean doVerifyIos(VerifyParams params, String url) {
|
||||
LOGGER.info("疯体 Ohayoo 登录验证-->{}",params.getOpenId());
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("token",params.getToken());
|
||||
jsonObject.put("product_code",params.getProductCode());
|
||||
jsonObject.put("uid",params.getOpenId());
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("token",params.getToken());
|
||||
map.put("product_code",params.getProductCode());
|
||||
map.put("uid",params.getOpenId());
|
||||
|
||||
boolean result = false;
|
||||
String r = HttpUtils.sendPost(url, jsonObject);
|
||||
|
||||
LOGGER.info("疯体 Ohayoo 请求结果:{}",r);
|
||||
|
||||
if (StringUtils.checkIsEmpty(r)){
|
||||
return false;
|
||||
String r = null;
|
||||
try {
|
||||
r = HttpUtils.doPost2(url, map);
|
||||
LOGGER.info("疯体 Ohayoo 请求结果:{}",r);
|
||||
JSONObject resultJson = JSON.parseObject(r);
|
||||
int status = resultJson.getIntValue("status");
|
||||
if(status == 0){
|
||||
result = true;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
JSONObject resultJson = JSON.parseObject(r);
|
||||
int status = resultJson.getIntValue("status");
|
||||
if(status == 0){
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,15 +7,13 @@ import org.apache.http.client.entity.UrlEncodedFormEntity;
|
|||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -40,6 +38,25 @@ public class HttpUtils {
|
|||
}
|
||||
}
|
||||
|
||||
public static String doPost2(String url, Map<String,String> parms) throws IOException {
|
||||
CloseableHttpClient httpclient = HttpClients.createDefault();
|
||||
HttpPost httpPost = new HttpPost(url);
|
||||
List<NameValuePair> nvps = getFromMap(parms);
|
||||
httpPost.setEntity(new UrlEncodedFormEntity(nvps));
|
||||
httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
CloseableHttpResponse response2 = httpclient.execute(httpPost);
|
||||
|
||||
try {
|
||||
HttpEntity entity = response2.getEntity();
|
||||
return EntityUtils.toString(entity);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
} finally {
|
||||
response2.close();
|
||||
}
|
||||
}
|
||||
|
||||
public static List<NameValuePair> getFromMap(Map<String,String> parms){
|
||||
List<NameValuePair> nvps = new ArrayList<NameValuePair>(parms.size());
|
||||
for(Map.Entry<String,String> item : parms.entrySet()){
|
||||
|
|
@ -131,7 +148,6 @@ public class HttpUtils {
|
|||
conn.setRequestProperty("accept", "*/*");
|
||||
conn.setRequestProperty("connection", "Keep-Alive");
|
||||
conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
|
||||
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
||||
// 发送POST请求必须设置如下两行
|
||||
conn.setDoOutput(true);
|
||||
conn.setDoInput(true);
|
||||
|
|
@ -142,8 +158,7 @@ public class HttpUtils {
|
|||
// flush输出流的缓冲
|
||||
out.flush();
|
||||
// 定义BufferedReader输入流来读取URL的响应
|
||||
in = new BufferedReader(
|
||||
new InputStreamReader(conn.getInputStream()));
|
||||
in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
String line;
|
||||
while ((line = in.readLine()) != null) {
|
||||
result += line;
|
||||
|
|
@ -168,9 +183,4 @@ public class HttpUtils {
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue