Calling a PHP script using FreePBX and Asterisk

隐身守侯 提交于 2019-12-01 13:30:06

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);
?>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!