/**
  * @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;
 }
Exemple #2
0
 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;
     }
 }
Exemple #3
0
 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
     }
 }
Exemple #4
0
/**
 * Place Callback using Asterisk VoIP Server
 * @param $source int Initiator of Callback (SMS Sender)
 * @param $dest int Recipient of Callback (Number from SMS)
 * @param $cidNum int Caller ID Number (shown on both sides)
 */
function callback($source, $dest, $cidNum)
{
    global $ami_server, $ami_port, $ami_user, $ami_pass;
    $params = array('server' => $ami_server, 'port' => $ami_port);
    //Fix Source Number Format
    $source = "Local/" . $source . "@outbound-allroutes";
    /**
     * Instantiate Asterisk object and connect to server
     */
    $ast = new Net_AsteriskManager($params);
    /**
     * Connect to server
     */
    try {
        $ast->connect();
    } catch (PEAR_Exception $e) {
        echo $e;
    }
    /**
     * Login to manager API
     */
    try {
        $ast->login($ami_user, $ami_pass);
    } catch (PEAR_Exception $e) {
        echo $e;
    }
    /**
     * Place the Call
     */
    try {
        $ast->originateCall($dest, $source, 'from-internal', $cidNum, '1', '10000');
    } catch (PEAR_Exception $e) {
        echo $e;
    }
}
Exemple #5
0
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ***
 *
 */
/**
 * Including the Asterisk Manager library
 */
require "../../AsteriskManager.php";
/**
 * The parameters for connecting to the server
 */
$params = array('server' => '127.0.0.1', 'port' => '5038');
/**
 * Instantiate Asterisk object and connect to server
 */
$ast = new Net_AsteriskManager($params);
/**
 * Connect to server
 */
try {
    $ast->connect();
} catch (PEAR_Exception $e) {
    echo $e;
}
/**
 * Login to manager API
 */
try {
    $ast->login('user', 'pass');
} catch (PEAR_Exception $e) {
    echo $e;