-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignl4_alert.php
More file actions
48 lines (37 loc) · 948 Bytes
/
signl4_alert.php
File metadata and controls
48 lines (37 loc) · 948 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
// Send SIGNL4 alert from PHP
// Your SIGNL4 team secret
$teamSecret = 'team-secret';
$url = 'https://connect.signl4.com/webhook/' . $teamSecret;
// User cURL
$ch = curl_init($url);
// Alert data
$data = array(
'Title' => 'Alert',
'Message' => 'SIGNL4 alert from PHP'
);
$jsonData = json_encode($data);
// Send the request
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // No echo for curl_errno
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
//Execute the request
$result = curl_exec($ch);
if (!curl_errno($ch)) {
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($http_code == 201) {
// Success
echo $result . '\r\n';
}
else {
// Error
echo 'Error: ' . $http_code . '\r\n';
}
}
else {
// Error
echo 'Error\r\n';
}
curl_close($ch);
?>