You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
908 B
33 lines
908 B
import java.net.HttpURLConnection;
|
|
import java.net.URL;
|
|
|
|
/**
|
|
* Compile: javac index.java
|
|
* Run: java Index
|
|
*/
|
|
class Index {
|
|
|
|
public static final String PUSH_URL = "https://example.com/api/push/key?status=up&msg=OK&ping=";
|
|
public static final int INTERVAL = 60;
|
|
|
|
public static void main(String[] args) {
|
|
while (true) {
|
|
try {
|
|
URL url = new URL(PUSH_URL);
|
|
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
|
con.setRequestMethod("GET");
|
|
con.getResponseCode();
|
|
con.disconnect();
|
|
System.out.println("Pushed!");
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
try {
|
|
Thread.sleep(INTERVAL * 1000);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
}
|