Hey there, for some reason my post request meaning to be: http://myurl.net/index.php?nmb=random_chars_etc wont work, here's my code:
import java.util.UUID; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.URL; import java.net.URLConnection; import java.net.URLEncoder; public class Main{ private static String uuid = UUID.randomUUID().toString().replaceAll("-", ""); public static void main(String[] args)throws Exception{ String data = URLEncoder.encode("nmb", "UTF-8") + "=" + URLEncoder.encode("test", "UTF-8"); URL url = new URL("http://myurl.net"); URLConnection conn = url.openConnection(); conn.setDoOutput(true); OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); wr.write(data); wr.flush(); BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line; while ((line = rd.readLine()) != null) { System.out.println(line); } wr.close(); rd.close(); } }
It definatlely reaches my page where I process the POST with php, however the UUID isnt sent over the url for some reason, a bit stuck..