Calling a PHP script using FreePBX and Asterisk

CaptainQuint

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

user3788685

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);
?>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Asterisk 3 way calling with IVR

From Dev

Calling a PHP script using ajax

From Dev

calling Elixir method using shell script

From Dev

Freepbx can't connect to asterisk wrong password

From Dev

Calling php scripts using ajax

From Dev

Send SMS from PHP script with FreePBX Bootstrap

From Dev

php calling bash script with multiple commands issue

From Dev

Calling a google apps script execution api from PHP using a service account

From Dev

Calling a php script at regular intervals with javascript

From Dev

Calling a Python Script from PHP

From Dev

Asterisk 3 way calling with IVR

From Dev

Calling a PHP script using ajax

From Dev

calling Elixir method using shell script

From Dev

Calling a Google App Script from PHP?

From Dev

Calling PHP script with Cordova

From Dev

Calling a php function using javascript

From Dev

Calling a php script using ajax not working

From Dev

How to create account balance for each users in asterisk freePBX system?

From Dev

Asterisk / Freepbx / Call doesn't disconnects after hangup

From Dev

asterisk random generation using rand in php

From Dev

Calling javascript function using php

From Dev

Calling a PHP in a for loop using AsyncHttpClient

From Dev

calling matlab from perl using a script

From Dev

Calling a google apps script execution api from PHP using a service account

From Dev

Calling things in <script> or using JavaScript?

From Dev

Asterisk* Originating a playback php script , but getting fwrite() broken pipe

From Dev

Calling a python script with arguments using subprocess

From Dev

How to create/remove users on FreePBX+Asterisk using REST ARI & PHP

From Dev

Calling function inside an onclick using Apps Script

Related Related

HotTag

Archive