本文整理汇总了PHP中AGI_AsteriskManager::send_request方法的典型用法代码示例。如果您正苦于以下问题:PHP AGI_AsteriskManager::send_request方法的具体用法?PHP AGI_AsteriskManager::send_request怎么用?PHP AGI_AsteriskManager::send_request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AGI_AsteriskManager
的用法示例。
在下文中一共展示了AGI_AsteriskManager::send_request方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: status_asterisk
/**
* Método para compactibilidade com código do snep, aqui há uma melhoria
* nas consultas simples reutilizando socket onde é possível.
*
* @param string $comando - Comando a ser executado
*
* @param string $quebra - Para retornar somente as linhas que contenham
* o conteudo dessa variável
*
* @param boolean $tudo - Esse parametro não é usado (?!)
*
* @return Dados da consulta
*/
public function status_asterisk($comando, $quebra, $tudo = False)
{
if ($comando != "Agents" && $comando != "Status") {
$cmd = self::$asterisk->command($comando);
$retorno = $cmd['data'];
if ($quebra != "") {
$ret_quebrado = " ";
foreach (explode("\n", $cmd['data']) as $line) {
if (preg_match("/{$quebra}/", $line)) {
$ret_quebrado .= $line;
break;
}
}
return $ret_quebrado;
} else {
return $cmd['data'];
}
} else {
// Enviando requisição de status
self::$asterisk->send_request($comando, array());
// Enviando esse objeto para cuidar dos responses
self::$asterisk->wait_event($this);
return $this->return;
}
}
示例2: AsteriskManagerAPI
function AsteriskManagerAPI($action, $parameters, $return_data = false)
{
global $arrLang;
$astman_host = "127.0.0.1";
$astman_user = 'admin';
$astman_pwrd = obtenerClaveAMIAdmin();
$astman = new AGI_AsteriskManager();
$astman->pagi = new dummy_pagi();
if (!$astman->connect("{$astman_host}", "{$astman_user}", "{$astman_pwrd}")) {
$this->errMsg = _tr("Error when connecting to Asterisk Manager");
} else {
$salida = $astman->send_request($action, $parameters);
$astman->disconnect();
if (strtoupper($salida["Response"]) != "ERROR") {
if ($return_data) {
return $salida;
} else {
return explode("\n", $salida["Response"]);
}
} else {
return false;
}
}
return false;
}
示例3: explode
function AsteriskManager_Originate($host, $user, $password, $command_data)
{
global $arrLang;
$astman = new AGI_AsteriskManager();
if (!$astman->connect("{$host}", "{$user}", "{$password}")) {
$this->errMsg = $arrLang["Error when connecting to Asterisk Manager"];
} else {
$parameters = $this->Originate($command_data['origen'], $command_data['destino'], $command_data['channel'], $command_data['description']);
$salida = $astman->send_request('Originate', $parameters);
$astman->disconnect();
if (strtoupper($salida["Response"]) != "ERROR") {
return explode("\n", $salida["Response"]);
} else {
return false;
}
}
return false;
}
示例4: array
$arr_channels = array("Active Channel(s)" => "core show channels", "Sip Channel(s)" => "sip show channels", "IAX2 Channel(s)" => "iax2 show channels");
$arr_peers = array("Sip Peers" => "sip show peers", "IAX2 Peers" => "iax2 show peers");
$arr_sip = array("Sip Registry" => "sip show registry", "Sip Peers" => "sip show peers");
$arr_iax = array("IAX2 Registry" => "iax2 show registry", "IAX2 Peers" => "iax2 show peers");
$arr_conferences = array("Conference Info" => "meetme");
$arr_subscriptions = array("Subscribe/Notify" => "core show hints");
$arr_voicemail = array("Voicemail users" => "voicemail show users");
$arr_queues = array("Queues Info" => "queue show");
$arr_database = array("Database Info" => "database show");
$amp_conf = parse_amportal_conf("/etc/amportal.conf");
$host = $amp_conf['MANAGERHOSTS'];
$astman = new AGI_AsteriskManager();
$res = $astman->connect($host, $amp_conf["AMPMGRUSER"], $amp_conf["AMPMGRPASS"]);
if ($res) {
//get version (1.4)
$response = $astman->send_request('Command', array('Command' => 'core show version'));
if (preg_match('/No such command/', $response['data'])) {
// get version (1.2)
$response = $astman->send_request('Command', array('Command' => 'show version'));
}
$verinfo = $response['data'];
} else {
// could not connect to asterisk manager, try console
$verinfo = exec('asterisk -V');
}
preg_match('/Asterisk (\\d+(\\.\\d+)*)(-?(\\S*))/', $verinfo, $matches);
$verinfo = $matches[1];
// $arr_all["Uptime"]="core show uptime";
// $arr_all["Active Channel(s)"]="core show channels";
// $arr_all["Subscribe/Notify"]="core show hints";
// $arr_all["Voicemail users"]="voicemail show users";
示例5: foreach
foreach (${$arr} as $key => $value) {
?>
<tr class="boxheader">
<td colspan="2" align="center"><h5><?php
echo _("{$key}");
?>
<hr></h5></td>
</tr>
<tr class="boxbody">
<td>
<table border="0" >
<tr>
<td>
<pre>
<?php
$response = $astman->send_request('Command', array('Command' => $value));
$new_value = $response['data'];
echo ltrim($new_value, 'Privilege: Command');
?>
</pre>
</td>
</tr>
</table>
</td>
</tr>
<?php
}
} else {
?>
<tr class="boxheader">
<td colspan="2" align="center"><h5><?php
示例6: while
continue;
}
if ($verbose > 2) {
echo "Connected to asterisk.\n";
}
//$res = $as->Ping();
$as->Events('agent,call');
$as->add_event_handler('Join', handle_handler);
$as->add_event_handler('Leave', idle_handler);
$as->add_event_handler('QueueCallerAbandon', handle_handler);
$as->add_event_handler('AgentCalled', handle_handler);
$as->add_event_handler('AgentDump', handle_handler);
$as->add_event_handler('AgentConnect', handle_handler);
$as->add_event_handler('AgentComplete', handle_handler);
$as->add_event_handler('QueueMemberRemoved', handle_handler);
$as->add_event_handler('QueueMemberAdded', handle_handler);
$as->add_event_handler('QueueMemberPaused', handle_handler);
$as->add_event_handler('QueueMemberStatus', idle_handler);
$as->add_event_handler('*', idle_handler);
while ($res = $as->send_request('WaitEvent')) {
if ($verbose > 1) {
echo "WaitEvent: " . $res['Response'] . "\n";
}
}
if ($verbose > 2) {
echo "After WaitEvent loop. Connection broken?\n";
}
}
/* But why should we make our manager events look like the ast_queue_log ones?
.. Stay tuned!
*/
示例7: array
function AsteriskManager_Command($command_data, $return_data = true)
{
global $arrLang;
$salida = array();
$astman = new AGI_AsteriskManager();
if (!$astman->connect("127.0.0.1", "admin", obtenerClaveAMIAdmin())) {
$this->errMsg = $arrLang["Error when connecting to Asterisk Manager"];
} else {
$salida = $astman->send_request('Command', array('Command' => "{$command_data}"));
$astman->disconnect();
$salida["Response"] = isset($salida["Response"]) ? $salida["Response"] : "";
if (strtoupper($salida["Response"]) != "ERROR") {
if ($return_data) {
return explode("\n", $salida["data"]);
} else {
return explode("\n", $salida["Response"]);
}
} else {
return false;
}
}
return false;
}
示例8: explode
function AsteriskManager_Hangup($host, $user, $password, $command_data)
{
$astman = new AGI_AsteriskManager();
$channel = "";
if (!$astman->connect("{$host}", "{$user}", "{$password}")) {
$this->errMsg = _tr("Error when connecting to Asterisk Manager");
} else {
//
$channelName = $command_data['channel'];
$arrChannel = explode("/", $channelName);
$pattern = "/^" . $arrChannel[0] . "\\/" . $arrChannel[1] . "/";
exec("/usr/sbin/asterisk -rx 'core show channels concise'", $output, $retval);
foreach ($output as $linea) {
if (preg_match($pattern, $linea, $arrReg)) {
$arr = explode("!", $linea);
$channel = $arr[0];
} else {
$channel = $channelName;
}
}
$parameters = array('Channel' => $channel);
$salida = $astman->send_request('Hangup', $parameters);
$astman->disconnect();
if (strtoupper($salida["Response"]) != "ERROR") {
return explode("\n", $salida["Response"]);
} else {
return false;
}
}
return false;
}
示例9: array
function AsteriskManager_Originate($host, $user, $password, $command_data)
{
global $arrLang;
$astman = new AGI_AsteriskManager();
if (!$astman->connect("{$host}", "{$user}", "{$password}")) {
$this->errMsg = $arrLang["Error when connecting to Asterisk Manager"];
} else {
/* Para poder pasar el parámetro Data correctamente, se debe usar
* un valor separado por barra vertical (|) en Asterisk 1.4.x y una
* coma en Asterisk 1.6.x. Para es se requiere detectar la versión
* de Asterisk.
*/
// CoreSettings sólo está disponible en asterisk 1.6.x
$r = $astman->send_request('CoreSettings');
$asteriskVersion = array(1, 4, 0, 0);
if ($r['Response'] == 'Success' && isset($r['AsteriskVersion'])) {
$asteriskVersion = explode('.', $r['AsteriskVersion']);
// CoreSettings reporta la versión de Asterisk
} else {
// no hay soporte CoreSettings en Asterisk Manager, se asume Asterisk 1.4.x.
}
$versionMinima = array(1, 6, 0);
while (count($versionMinima) < count($asteriskVersion)) {
array_push($versionMinima, 0);
}
while (count($versionMinima) > count($asteriskVersion)) {
array_push($asteriskVersion, 0);
}
$sSeparador = $asteriskVersion >= $versionMinima ? ',' : '|';
$parameters = $this->Originate($command_data['device'], $command_data['callerid'], $command_data['room'], $sSeparador);
$salida = $astman->send_request('Originate', $parameters);
$astman->disconnect();
if (strtoupper($salida["Response"]) != "ERROR") {
return explode("\n", $salida["Response"]);
} else {
return false;
}
}
return false;
}
示例10: array
function AsteriskManager_Command($host, $user, $password, $command_data)
{
global $arrLang;
$salida = array();
$astman = new AGI_AsteriskManager();
//$salida = array();
if (!$astman->connect("{$host}", "{$user}", "{$password}")) {
$this->errMsg = $arrLang["Error when connecting to Asterisk Manager"];
} else {
foreach ($command_data as $key => $valor) {
$salida = $astman->send_request('Command', array('Command' => "{$valor}"));
}
$astman->disconnect();
$salida["Response"] = isset($salida["Response"]) ? $salida["Response"] : "";
if (strtoupper($salida["Response"]) != "ERROR") {
return explode("\n", $salida["Response"]);
} else {
return false;
}
}
return false;
}