FreePBX API to make call via PHP Script

Hello everyone, I want to be able to make a call from my website through my FreePBX. I can’t find an API that allows you to create a call by sending the number to call and the destination extension.
Can you help me ?

Some Options:

you basically just create call files in a temp directory, ensure they are owned by the asterisk user, and then move them into /var/spool/asterisk/outgoing

Thanks for your reply, with your message and many search on the web, I found this class on github : keynertyc/click-to-call
In the FreePBX, can you say me where I can run a php script ? In the www directory ?
Other question, in my case, which context can I use ? Where can show the currents contexts ?

In addition to AGI, there is also the Asterisk Manager Interface (AMI). You could look into using AJAM to enable AMI over HTTP:

Just make sure you setup a new Asterisk Manager user/pass (ideally locked down with a permit/deny entry matching your web server) with more restricted permissions so exploitation of your site doesn’t result in a hijack of the PBX, as well. You’d basically give the needed originate and call write permissions and that’s it…disable read&write on anything else.

Whether you go AGI or AMI mostly depends on what all you want to do and how you are developing the site or application in question. AGI can be easier to implement in web sites, but I would argue that AMI has seen more modern support and development. Some of the external libraries and such out there for AGI haven’t been updated in a long while. phpagi, for example, has been at v2.20 for literally a decade now without any official updates or patches. Some have forked it and continued maintaining it, yes, but YMMV.

Just do your research. Eventually, RESTful API will likely support origination too (not yet, though), and that will be the way to go in the future.

Hi every body, someone can help me please for this question ?

@TheWebMachine already told you it depends on what you choose (AMI, AGI or ARI), but there is flexibility. I recommend reading the following:
Asterisk Gateway Interface:
Asterisk Manager Interface:
Asterisk Rest Interface:

See above.

find /etc/asterisk/ -name "extension" -print

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.