Just wondering how I'd send an HTTP GET Request. For an example: http://localhost/test?username=username&email=email Thanks!
by GET i assume you want to return the content on the webpage? Code: public static String get(String url) { string stuff; try { URL url = new URL(url); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); String str = in.readLine(); in.close(); if (str != null) { stuff = str; } } catch (java.io.IOException e1) { stuff = e1.getMessage(); } return stuff; }
What I'm trying to do is send information to a PHP site. So for an example, if I want to send the players username for my PHP server to do stuff with I can.
Ok. Say I want to send information from my plugin, to a php script I have on my web server. For an example "http://mywebsite.com/test.php?id=16". How would I do this in the most simple way possible?
The example that zack6849 gave should be sufficient, just call his get() function with the url, e.g. get("http://mywebsite.com/test.php?id=16").
Yup, got it all figured out. Now just out of curiosity, what if I want to read the contents of a website, and constantly do so (Or at least every couple of seconds)? What would the code look like for that? Would it lag the server?
Do bukkit schedulers lag the server? I'm going to probably want to check the website every couple of seconds. Would that put strain on the server?