Your All-in-One Toolkit
Supports custom message push, which can be implemented via cURL, PHP, and Java. Here are some examples:
curl -X POST "https://msg.wukongsoftware.com/sendmsg" \
-H "Content-Type: application/json" \
-d '{
"clientPushID": "Push ID",
"msgTitle": "Test Message",
"msgContent": "This is a test push message"
}'
<?php
// API URL
$url = "https://msg.wukongsoftware.com/sendmsg";
// Request parameters (replace with actual push ID)
$postData = [
"clientPushID" => "Push ID",
"msgTitle" => "Test Message",
"msgContent" => "This is a test push message"
];
// Convert array to JSON string
$jsonData = json_encode($postData);
// Set request context (simulate POST request, add headers)
$contextOptions = [
'http' => [
'method' => 'POST',
'header' => [
'Content-Type: application/json',
'Content-Length: ' . strlen($jsonData) // Optional, but recommended
],
'content' => $jsonData,
'timeout' => 10 // Request timeout (seconds)
]
];
// Create context resource
$context = stream_context_create($contextOptions);
// Send request and get response
try {
$response = file_get_contents($url, false, $context);
if ($response === false) {
// Get error information
$error = error_get_last();
throw new Exception("Request failed: " . $error['message']);
}
// Output response result
echo "Response: " . $response . PHP_EOL;
// Parse JSON response (if needed)
$responseData = json_decode($response, true);
if (json_last_error() !== JSON_ERROR_NONE) {
echo "JSON parsing failed" . PHP_EOL;
}
} catch (Exception $e) {
echo "Request exception: " . $e->getMessage() . PHP_EOL;
}
?>
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
public class PostJsonRequest {
// API URL
private static final String API_URL = "https://msg.wukongsoftware.com/sendmsg";
public static void main(String[] args) {
try {
// 1. Create URL object
URL url = new URL(API_URL);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
// 2. Set request parameters
conn.setRequestMethod("POST"); // Request method
conn.setRequestProperty("Content-Type", "application/json"); // Request header
conn.setDoOutput(true); // Allow output (send POST data)
conn.setConnectTimeout(10000); // Connection timeout (10 seconds)
conn.setReadTimeout(10000); // Read timeout (10 seconds)
// 3. Construct JSON request body
String jsonInputString = "{"
+ "\"clientPushID\":\"Push ID\","
+ "\"msgTitle\":\"Test Message\","
+ "\"msgContent\":\"This is a test push message\""
+ "}";
// 4. Send request body
try (DataOutputStream wr = new DataOutputStream(conn.getOutputStream())) {
wr.writeBytes(jsonInputString);
wr.flush();
}
// 5. Get response code and response content
int responseCode = conn.getResponseCode();
System.out.println("Response code: " + responseCode);
// Read response content
BufferedReader in;
if (responseCode >= 200 && responseCode < 300) {
in = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8));
} else {
// Read error response (e.g., 400/500)
in = new BufferedReader(new InputStreamReader(conn.getErrorStream(), StandardCharsets.UTF_8));
}
String inputLine;
StringBuilder response = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
// 6. Output response result
System.out.println("Response content: " + response.toString());
// Close connection
conn.disconnect();
} catch (Exception e) {
e.printStackTrace();
}
}
}