Skip to content

Instantly share code, notes, and snippets.

Created April 8, 2015 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/85fda3d944f74de25ac7 to your computer and use it in GitHub Desktop.
Save anonymous/85fda3d944f74de25ac7 to your computer and use it in GitHub Desktop.
public void Post() {
String urlStr = "http://www.zimuzu.tv/User/Login/ajaxLogin";
String send = "account=xxx&password=xxx&from=loginpage&remember=0";
try {
URL url = new URL(urlStr);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setConnectTimeout(10000);
conn.setReadTimeout(10000);
conn.setRequestProperty("Connection", "keep-alive");
conn.setRequestProperty("Accept-Encoding", "gzip, deflate");
conn.connect();
DataOutputStream out = new DataOutputStream(conn.getOutputStream());
out.write(send.getBytes());
out.flush();
out.close();
InputStream in = conn.getInputStream();
BufferedReader buffer = new BufferedReader(new InputStreamReader(in));
String s;
StringBuilder str = new StringBuilder();
while ((s = buffer.readLine()) != null) {
str.append(s);
}
System.out.print(conn.getResponseCode() + "\n" + str.toString());
} catch (Exception e) {
e.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment