-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass.prowl.php
More file actions
53 lines (39 loc) · 1.57 KB
/
class.prowl.php
File metadata and controls
53 lines (39 loc) · 1.57 KB
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
49
50
51
52
53
<?php
function prowl($apikey, $application, $event, $description, $priority, $event_url) {
$api_url = "https://api.prowlapp.com/publicapi/add";
$data = "apikey=". urlencode($apikey) . "&priority=" . urlencode($priority) . "&application=" . urlencode($application) . "&event=" . urlencode($event) . "&description=" . urlencode($description) . "&url=" . urlencode($event_url) ;
$ch = curl_init($api_url);
//curl_setopt($ch, CURLOPT_USERPWD, $this->username .":". $this->password);
//curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$return = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
# Invalid username/password
if($httpcode == "401"):
return array("success" => "y",
"error" => $httpcode . "",
"error_code" => "",
"url" => $api_url,
"data" => $data);
# No application/event defined
elseif($httpcode == "400"):
return array("success" => "y",
"error" => $httpcode . "",
"error_code" => "",
"url" => $api_url,
"data" => $data);
# All ok!
endif;
return array("success" => "y",
"error" => $httpcode . "",
"error_code" => "",
"url" => $api_url,
"data" => $data);
}
?>