doujian3132 2012-08-07 12:16
浏览 110
已采纳

星号。 PHP。 如果我知道SIP,如何获得电话号码?

We have asterisk server and GSM gateway. I need to know phone numbers that calls to asterisk in the current time. Now I can get SIP with command core show channels but I don't know how to get phone numbers. I use phpAGI library:

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

1条回答 默认 最新

  • doukao5073 2012-08-07 12:28
    关注

    The first line of the 'core show channels' output is the channel ID. use it to issue the command core show channel <id> (no 's' at the end of channel!) to see more info about the channel, including the number of the calling party.

    foreach(explode("
    ", $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
    ", $matches[1]);
       }
       else {
          printf("No phone number found for SIP Channel ID %s
    ", $col[0]);
       }
    }
    

    Tested with Asterisk 1.8, your version may give different results. Just check a sample output of core show channel.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口