function hipchat_alert($message) { include '/opt/dcimstack/vendor/autoload.php'; $user = "******"; $token = "API TOKEN"; $room = "HIPCHAT ROOM"; $hc = new HipChat\HipChat($token); // send a message to the 'Development' room from 'API' $hc->message_room($room, $user, $message); }
public function execute() { $hipChat = new \HipChat\HipChat($this->authToken); $message = $this->phpci->interpolate($this->message); $result = true; if (is_array($this->room)) { foreach ($this->room as $room) { if (!$hipChat->message_room($room, 'PHPCI', $message, $this->notify, $this->color)) { $result = false; } } } else { if (!$hipChat->message_room($this->room, 'PHPCI', $message, $this->notify, $this->color)) { $result = false; } } return $result; }
private function send_hipchat_notification($message) { require_once $this->plugindir . 'HipChat' . DIRECTORY_SEPARATOR . 'HipChat.php'; $token = qa_opt('hipchat_notifications_api_token'); $room = qa_opt('hipchat_notifications_room_name'); $sender = qa_opt('hipchat_notifications_sender'); $color = qa_opt('hipchat_notifications_color'); $notify = qa_opt('hipchat_notifications_notify') > 0 ? true : false; if ($sender == null || $sender == '') { $sender = 'Question2Answer'; } if ($color == null || $color == '') { $color = 'yellow'; } if ($token && $room) { $hc = new HipChat\HipChat($token); try { $result = $hc->message_room($room, $sender, $message, $notify, $color); } catch (HipChat\HipChat_Exception $e) { error_log($e->getMessage()); } } }
#!/usr/bin/php <?php require 'src/HipChat/HipChat.php'; if (!isset($argv[1])) { echo "Usage: {$argv['0']} <token> [target]\n"; die; } $token = $argv[1]; $target = isset($argv[2]) ? $argv[2] : 'https://api.hipchat.com'; $hc = new HipChat\HipChat($token, $target); echo "Testing HipChat API.\nTarget: {$target}\nToken: {$token}\n\n"; // get rooms echo "Rooms:\n"; try { $rooms = $hc->get_rooms(); foreach ($rooms as $room) { echo "Room {$room->room_id}\n"; echo " - Name: {$room->name}\n"; $room_data = $hc->get_room($room->room_id); echo " - Participants: " . count($room_data->participants) . "\n"; } } catch (HipChat\HipChat_Exception $e) { echo "Oops! Error: " . $e->getMessage(); } // get users echo "\nUsers:\n"; try { $users = $hc->get_users(); foreach ($users as $user) { echo "User {$user->user_id}\n"; echo " - Name: {$user->name}\n";
<?php require "libraries/HipChat.php"; $hcToken = "HIPCHAT_TOKEN"; $roomName = 'ROOM_NAME'; $from = 'BULUTFON'; if (isset($_POST['caller']) && isset($_POST['event_type']) && isset($_POST['callee'])) { $event_type = $_POST['event_type']; $caller = $_POST['caller']; $callee = $_POST['callee']; $hc = new HipChat\HipChat($hcToken); $hc->set_verify_ssl(false); if ($event_type == 'call_init') { $message = "{$caller} - {$callee}'yi arıyor."; $color = 'green'; } else { if ($event_type == 'call_hangup') { $message = "{$caller} ile {$callee} arasındaki görüşme sonlandı."; $color = 'red'; } else { $message = "{$caller}'dan yeni faks geldi"; $color = 'gray'; } } $hc->message_room($roomName, $from, $message, true, $color); }
public function sendMessage($message) { $hc = new \HipChat\HipChat($this->token); $hc->message_room($this->room, $this->from, $message, true, 'random'); }
// bir hash ile guvenligimizi biraz daha artirabiliriz. $hash = isset($_GET['hash']) ? $_GET['hash'] : false; if ($hash != $hashValue || !$caller) { json(['error' => 'parameters missing']); } $conn = new PDO("mysql:host=localhost;dbname={$db_name}", $db_username, $db_password); // Gonderilen veriye bfxm formatinda cevap vermemiz gerekmekte. // Herhangi bir zincirleme islem( kullanicidan bir tusa basmasini istemek ) yapmayacagimizdan // kullaniciyi karsilama menu grubuna yonlendirebilirz. $cevap = array("bfxm" => array("version" => 1), "seq" => array(array("action" => "dial", "args" => array("destination" => $welcome)))); // WHMCS uzerinden telefon numarasina gore kullaniciyi bulalim. $query = $conn->prepare("SELECT tblclients.id,\n\t\ttblclients.firstname,\n\t\ttblclients.lastname,\n\t\ttblcustomfieldsvalues.value AS telefon \n\tFROM tblcustomfieldsvalues \n\tLEFT JOIN tblclients ON tblclients.id=tblcustomfieldsvalues.relid \n\tWHERE tblcustomfieldsvalues.value LIKE ? AND tblcustomfieldsvalues.fieldid=?"); $query->execute(["%{$caller}%", $fieldID]); $profile = $query->fetch(PDO::FETCH_OBJ); if ($profile) { // Kullanicimiz varsa kullanicinin son 5 destek biletine ulasalim. $query = $conn->prepare("SELECT id,title FROM tbltickets WHERE userid=? AND status!='Closed' ORDER BY id DESC LIMIT 5"); $query->execute([$profile->id]); $tickets = $query->fetchAll(PDO::FETCH_OBJ); $liste = ""; if ($tickets) { $liste = "<ul>"; foreach ($tickets as $p) { $liste .= "<br><li> <a href='{$url}supporttickets.php?action=view&id={$p->id}'>{$p->title}</a></li>"; } $liste .= "</ul>"; } $hc = new HipChat\HipChat($hcToken); $hc->message_room($roomName, $from, "<b>{$profile->firstname} {$profile->lastname} </b> ({$caller}) arıyor. {$liste}", true, 'random'); } json($cevap);
/** * Sends the message to HipChat * * @param string The message you want to send */ private function sendToHipchat($message) { $hipchatToken = QUEUE_MONITOR_HIPCHAT_TOKEN; $hipchatRoomID = QUEUE_MONITOR_HIPCHAT_ROOM; $fromName = 'Queue Monitor'; $notify = 1; $color = 'yellow'; $hipchatConnection = new HipChat\HipChat($hipchatToken); try { $result = $hipchatConnection->message_room($hipchatRoomID, $fromName, $message, $notify, $color); } catch (HipChat\HipChat_Exception $e) { $this->out("Failed to alert to hipchat: " . $e->getMessage()); $result = false; } }
/** * Tests for a mention at the first position in the message. * * In PHP, curl uses the syntax "@test.php" to send *the file* * test.php via curl. * * This test should actually just work (i.e. not throwing an exception) * * @link http://www.php.net/manual/en/function.curl-setopt.php see reference for CURLOPT_POSTFIELDS */ public function testMentionAtFirstPosition() { $hc = new HipChat\HipChat('hipchat-php-test-token', $this->target); $hc->message_room(123, '@sender', '@test test'); }