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

使用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

图片转代码服务由CSDN问答提供 功能建议

所以我通过FreePBX服务器设置了VOIP系统。 我想拥有它,以便当FreePBX接听新的呼叫时,星号会将呼叫者ID和呼叫ID发送到php脚本,然后PHP脚本将使用该信息来收集与该呼叫者ID相关的帐户的票证信息。 。 然后,它将使用找到的信息更新数据库。 当用户接听电话时,我想将用户的分机和呼叫ID发送到另一个php脚本,并使用新信息更新数据库。

我已经研究过PHPARI,但是我缺乏文档。 我只需要一种方式,PHPARI和类似的库似乎专注于从我所理解的两个方面走。

我的互联网搜索没有产生任何东西,所以我转向 给你们的帮助和指导。

FreePBX版本:13.0.83 星号版本: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);
    ?>
    
    点赞 评论

相关推荐 更多相似问题