dongyu9667 2016-03-17 14:46
浏览 215
已采纳

使用FreePBX和Asterisk调用PHP脚本

So I have a VOIP system set up through a FreePBX server. I want to have it so that when a new call is picked up by FreePBX, asterisks will send the caller ID and the call ID to a php script, which will then use that information to gather ticket information for the account related to that caller ID. It will then update a database with the found information. When a user answers the phone, I then want to send the user's extension and the call ID to another php script and update the database with the new information.

I have looked into PHPARI, but the documentation is lacking for me. I just need it to go one way, and PHPARI and similar libraries seem to focus on going both ways, from what I've understood.

My internet searches have yielded nothing, so I turn to you guys for help and guidance.

FreePBX Version: 13.0.83 Asterisk Version: 13.7.1

  • 写回答

1条回答 默认 最新

  • douxi1738 2016-03-17 17:50
    关注

    Have a look at Asterisk AGI you should be able to script it through the dial plan (extensions.conf) and include any vars like caller ID.

    I've done a quick test from my extension.conf;

    s is used to catch where no called number is used in the context.

    exten => s,1,Verbose(Incoming call from Sip line CallerID=${CALLERID(all)})
    exten => s,2,AGI(phone.php,${CALLERID(all)})
    exten => s,3,Goto(internal-ext,3001,1)
    

    my phone.php is located at /var/lib/asterisk/agi-bin/phone.php Pass your vars as script.php,<var>,<var>...

    Don't use script.php?callNum= as that's only valid for web applications, this should be treated as command line.

    That script writes to a file at /tmp/phone which is updated with the calling caller id.

    In my php script I did the following;

    #!/usr/bin/php
    
    <?php
        $query = $argv[1];
        $file = fopen("/tmp/phone", "w");
            fwrite($file,$query);
            fclose($file);
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)