-
Notifications
You must be signed in to change notification settings - Fork 2
/
push.inc.php
46 lines (42 loc) · 1.35 KB
/
push.inc.php
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
<?php
// Set your ChurchTools URL.
const CT_URL = '...';
// Pushover, put in your own credentials below and set service to "true" if needed
const PUSHOVER = false;
const PUSHOVER_TOKEN = '...';
const PUSHOVER_USER = '...';
// Pushover Integration
function pushover($title, $message, $priority = 0, $retry = null, $expire = null): bool {
if(!isset($title, $message)) {
return false;
}
$c = curl_init();
curl_setopt($c, CURLOPT_URL, 'https://api.pushover.net/1/messages.xml');
curl_setopt($c, CURLOPT_HEADER, false);
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_POSTFIELDS, array(
'token' => PUSHOVER_TOKEN,
'user' => PUSHOVER_USER,
'title' => $title,
'message' => $message,
'html' => 1,
'device' => '',
'priority' => $priority,
'timestamp' => time(),
'expire' => $expire,
'retry' => $retry,
'callback' => '',
'url' => CT_URL,
'sound' => '',
'url_title' => CT_URL
));
$response = curl_exec($c);
$xml = simplexml_load_string($response);
return $xml->status == 1;
}
function push($title, $message, $priority = 0, $retry = null, $expire = null): void {
if (PUSHOVER) {
pushover($title, $message, $priority, $retry, $expire);
}
}