Created
April 8, 2015 08:25
-
-
Save anonymous/85fda3d944f74de25ac7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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