mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-07-20 05:30:59 -04:00
Push Examples (#3735)
This commit is contained in:
parent
9c24cd3973
commit
9ef1e69ae0
13 changed files with 178 additions and 0 deletions
32
extra/push-examples/java/index.java
Normal file
32
extra/push-examples/java/index.java
Normal file
|
@ -0,0 +1,32 @@
|
|||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue