I login to a server (php page) using the code below:
$curl -b cookies --output 'result' \
--data 'user=me@myself.com' \
--data 'password=donttellanyone' \
http://ift.tt/1JxDJA3
After executing this command in terminal, a file named result will be created and inside it is just a html page that says login success.
But I now want to do the same thing using a Java console application...but I havent got any success yet. Executing this Java code results in error. I guess it is because I am not giving username and password in a correct way.
This is my code:
URL url = new URL("http://ift.tt/1jbM0iA");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("Cookie", "username=" + email + "; password=" + pwd);
conn.connect();
So the question is how to convert the above curl command to Java code?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire