1

我们有星号服务器和 GSM 网关。我需要知道当前时间拨打星号的电话号码。现在我可以通过命令获取 SIP,core show channels但我不知道如何获取电话号码。我使用 phpAGI 库:

$agi_manager = new AGI_AsteriskManager(null, $agi_config);
$connect = $agi_manager->connect();
$result = $agi_manager->command('core show channels');
4

1 回答 1

1

'core show channels' 输出的第一行是频道 ID。使用它来发出命令core show channel <id>(频道末尾没有's'!)以查看有关频道的更多信息,包括主叫方的号码。

foreach(explode("\n", $result) as $line) {
   $cols = explode(" ", $line);
   $result2 = $agi_manager->command('core show channel '.$col[0]);
   if(preg_match('/Connected Line ID:\s*(\d+)/', $result2, $matches) {
      printf("Phone number: %s\n", $matches[1]);
   }
   else {
      printf("No phone number found for SIP Channel ID %s\n", $col[0]);
   }
}

使用 Asterisk 1.8 测试,您的版本可能会给出不同的结果。只需检查core show channel.

于 2012-08-07T12:28:20.190 回答