Fixed hipchat transport

This commit is contained in:
laf
2015-12-08 23:09:27 +00:00
parent a2d97f4283
commit c5b708d931

View File

@ -27,14 +27,20 @@ foreach($opts as $option) {
$api = str_replace("%".$key, $method == "get" ? urlencode($value) : $value, $api); $api = str_replace("%".$key, $method == "get" ? urlencode($value) : $value, $api);
} }
$curl = curl_init(); $curl = curl_init();
$data = array(
"message" => $obj["msg"], if (empty($option["message_format"])) {
"room_id" => $option["room_id"], $option["message_format"] = 'text';
"from" => $option["from"], }
"color" => $option["color"],
"notify" => $option["notify"], $data[] = "message=".urlencode($obj["msg"]);
"message_format" => $option["message_format"] $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 // Sane default of making the message color green if the message indicates
// that the alert recovered. // that the alert recovered.
if(strstr($data["message"], "recovered")) { if(strstr($data["message"], "recovered")) {
@ -44,6 +50,9 @@ foreach($opts as $option) {
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data); curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/x-www-form-urlencoded',
));
$ret = curl_exec($curl); $ret = curl_exec($curl);
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE); $code = curl_getinfo($curl, CURLINFO_HTTP_CODE);