/** * @param string $phoneNumber * @param string $name * * @return bool * @throws ATSException */ public function organizeCall($phoneNumber, $name) { try { require_once __DIR__ . "/../../../../../../lib/asterisk-php-manager/AsteriskManager.php"; $config = (require_once __DIR__ . "/../config/ATSConfig.php"); $params = ['server' => $config['server'], 'port' => $config['port']]; $ast = new Net_AsteriskManager($params); try { $ast->connect(); } catch (\Exception $e) { throw new ATSException('Unable to connect!'); } try { $ast->login($config['login'], $config['password']); } catch (\Exception $e) { throw new ATSException('Unable to login!'); } try { $result = $ast->originateCall($phoneNumber, 'SIP/voximplant', 'from-internal', $name . $phoneNumber, 1, 30000, null, uniqid('call', true)); $ast->logout(); $ast->close(); if (strpos($result, 'Success') === false) { throw new ATSException('Unable to call!'); } } catch (\Exception $e) { throw new ATSException('Unable to call!'); } } catch (\Exception $e) { // some logging throw new ATSException('Call was not organized!'); } return true; }
public function showQueue() { try { $oAsteriskLogin = $this->_getConfigManager(); //get agent_id based on agent number $astParams = array('server' => '127.0.0.1', 'port' => '5038'); $oAIM = new Net_AsteriskManager($astParams); $oAIM->connect(); $result = $oAIM->login($oAsteriskLogin[0], $oAsteriskLogin[1]); $result = $oAIM->_sendCommand("Action: EVENTS\r\n" . "EVENTMASK: OFF\r\n\r\n"); $result = $oAIM->getQueues(); $oAIM->logout(); $oAIM->close(); return $this->convertJsonData($result); } catch (Exception $e) { $this->errMsg = '(internal) showQueue failed: ' . $e->getMessage(); return FALSE; } }
function spycall($agent_number, $supervisor_queue, $whisper) { try { $oAsteriskLogin = $this->_getConfigManager(); $spy_number = '771'; //($whisper?'771':'772'); //$channel = 'Local/'.$supervisor_queue.'@ext-queues'; $channel = 'SIP/' . $supervisor_queue; $var = array('AGENT' => $agent_number, 'WHISPER' => $whisper ? 'w' : ''); $astParams = array('server' => '127.0.0.1', 'port' => '5038'); $oAIM = new Net_AsteriskManager($astParams); $oAIM->connect(); $result = $oAIM->login($oAsteriskLogin[0], $oAsteriskLogin[1]); $result = $oAIM->_sendCommand("Action: EVENTS\r\n" . "EVENTMASK: OFF\r\n\r\n"); $result = $oAIM->originateCall($spy_number, $channel, 'from-internal', $agent_number, 1, 30000, $var, null); $oAIM->logout(); $oAIM->close(); return $result; } catch (PEAR_Exception $e) { $this->errMsg = '(internal) spycall: ' . $e->getMessage(); return TRUE; //work arround for right action but show error } }