資源簡介
獲取微信沙箱操作的key,代碼中返回的沙箱key值替換原有的key做簽名就可以了,下載后有不清楚的可以私我

代碼片段和文件信息
package?test;
import?java.io.BufferedReader;
import?java.io.IOException;
import?java.io.InputStreamReader;
import?java.io.OutputStreamWriter;
import?java.net.HttpURLConnection;
import?java.net.URL;
import?java.net.URLConnection;
//發起post請求,并且獲取服務器返回
public?class?HttpUtil?{
private?final?static?int?CONNECT_TIMEOUT?=?5000;//
private?final?static?String?DEFAULT_ENCODING=“UTF-8“;
public?static?String?postData(String?urlStrString?data)?{
return?postData(urlStr?datanull);
}
public?static?String?postData(String?urlStrString?dataString?contentType)?{
BufferedReader?reader?=?null;
try?{
URL?url?=?new?URL(urlStr);
// URLConnection?coon?=url.openConnection();
HttpURLConnection?coon?=?(HttpURLConnection)?url.openConnection();
coon.setRequestMethod(“POST“);
coon.setDoOutput(true);//為true后可使用.getOutputStrean
coon.setConnectTimeout(CONNECT_TIMEOUT);//設置連接主機超時(ms)
coon.setReadTimeout(CONNECT_TIMEOUT);//設置從主機讀取數據超時(ms)
if(contentType!=null)?{
coon.setRequestProperty(“content_type“?contentType);
}
OutputStreamWriter?writer?=?new?OutputStreamWriter(coon.getOutputStream()DEFAULT_ENCODING);//將寫入的字符編碼成字節后寫入一個字節流
if(data==null)?{
data=““;
}
writer.write(data);
writer.flush();
writer.close();
reader?=?new?BufferedReader(new?InputStreamReader(coon.getInputStream()?DEFAULT_ENCODING));//緩沖字符輸入流
StringBuilder?sb?=?new?StringBuilder();
String?line?=?null;
while((line?=?reader.readLine())!=null)?{
sb.append(line);
sb.append(“\r\n“);
}
return?sb.toString();
}catch?(IOException?e)?{??
????????????//logger.error(“Error?connecting?to?“?+?urlStr?+?“:?“?+?e.getMessage());?
e.printStackTrace();
????????}?finally?{??
????????????try?{??
????????????????if?(reader?!=?null)??
????????????????????reader.close();??
????????????}?catch?(IOException?e)?{??
????????????}??
????????}??
????????return?null;??
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1039??2018-10-08?09:31??getSignKey.txt
?????文件???????2098??2018-08-29?09:00??HttpUtil.java
-----------?---------??----------?-----??----
?????????????????3137????????????????????2
- 上一篇:報警聲音大全__WAV
- 下一篇:基于LabVIEW的虛擬振動測試儀
評論
共有 條評論