号簿助手 v4.6.31版本的 MD5 值为:9d7ff98a6bb5cc178eac2df4d1b2f0e0
以下内容为反编译后的 Request.java 源代码,内容仅作参考
package com.yulore.collect.network;
import android.os.Build;
import com.yulore.collect.log.Logger;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;
public class Request {
private static final String DEFAULT_PARAMS_ENCODING = "UTF-8";
protected static final String HEADER_CONTENT_TYPE = "Content-Type";
protected static final String HTTP_POST_URL = "http://stat.dianhua.cn/stat/collect/post.php";
protected static final String TAG = "Request";
protected static final int TIME_OUT = 50000;
public boolean performRequest(Map<String, String> params) {
if (params == null || params.size() == 0) {
return false;
}
Logger.d(TAG, "SDK_INT: " + Build.VERSION.SDK_INT);
if (Build.VERSION.SDK_INT >= 9) {
return new HurlRequest().performRequest(params);
}
return new HttpClientRequest().performRequest(params);
}
public String getParamsEncoding() {
return "UTF-8";
}
public String getBodyContentType() {
return "application/x-www-form-urlencoded; charset=" + getParamsEncoding();
}
public byte[] encodeParameters(Map<String, String> params, String paramsEncoding) {
StringBuilder encodedParams = new StringBuilder();
try {
for (Map.Entry<String, String> entry : params.entrySet()) {
encodedParams.append(URLEncoder.encode(entry.getKey(), paramsEncoding));
encodedParams.append('=');
encodedParams.append(URLEncoder.encode(entry.getValue(), paramsEncoding));
encodedParams.append('&');
}
return encodedParams.toString().getBytes(paramsEncoding);
} catch (UnsupportedEncodingException uee) {
throw new RuntimeException("Encoding not supported: " + paramsEncoding, uee);
}
}
public boolean parserStatus(String data) {
try {
JSONObject jsonObject = new JSONObject(data);
int responseStatus = jsonObject.optInt("status", -1);
Logger.d(TAG, "responseStatus: " + responseStatus);
return responseStatus == 0;
} catch (JSONException e) {
e.printStackTrace();
return false;
}
}
}