-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass.prowl.php
More file actions
47 lines (31 loc) · 1.33 KB
/
Copy pathclass.prowl.php
File metadata and controls
47 lines (31 loc) · 1.33 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
<?php
function prowl($apikey, $application, $event, $description, $priority, $url) {
$url = "https://api.prowlapp.com/publicapi/add?apikey=". urlencode($apikey) . "&priority=" . urlencode($priority) . "&application=" . urlencode($application) . "&event=" . urlencode($event) . "&description=" . urlencode($description) . "&url=" . urlencode($url) ;
$ch = curl_init($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_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" => "n",
"error" => "Invalid username/password",
"error_code" => "401");
# No application/event defined
elseif($httpcode == "400"):
return array("success" => "n",
"error" => "No application/event defined",
"error_code" => "400");
# All ok!
endif;
return array("success" => "y",
"error" => "",
"error_code" => "");
}
?>