mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fixed hipchat transport
This commit is contained in:
@ -27,14 +27,20 @@ foreach($opts as $option) {
|
||||
$api = str_replace("%".$key, $method == "get" ? urlencode($value) : $value, $api);
|
||||
}
|
||||
$curl = curl_init();
|
||||
$data = array(
|
||||
"message" => $obj["msg"],
|
||||
"room_id" => $option["room_id"],
|
||||
"from" => $option["from"],
|
||||
"color" => $option["color"],
|
||||
"notify" => $option["notify"],
|
||||
"message_format" => $option["message_format"]
|
||||
);
|
||||
|
||||
if (empty($option["message_format"])) {
|
||||
$option["message_format"] = 'text';
|
||||
}
|
||||
|
||||
$data[] = "message=".urlencode($obj["msg"]);
|
||||
$data[] = "room_id=".urlencode($option["room_id"]);
|
||||
$data[] = "from=".urlencode($option["from"]);
|
||||
$data[] = "color=".urlencode($option["color"]);
|
||||
$data[] = "notify=".urlencode($option["notify"]);
|
||||
$data[] = "message_format=".urlencode($option["message_format"]);
|
||||
|
||||
$data = implode('&', $data);
|
||||
|
||||
// Sane default of making the message color green if the message indicates
|
||||
// that the alert recovered.
|
||||
if(strstr($data["message"], "recovered")) {
|
||||
@ -44,6 +50,9 @@ foreach($opts as $option) {
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/x-www-form-urlencoded',
|
||||
));
|
||||
$ret = curl_exec($curl);
|
||||
|
||||
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||
|
Reference in New Issue
Block a user