FreePBX API to make call via PHP Script


(Rom1906) #1

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 ?
Thanks


(Communication Technologies) #2

Some Options:

https://wiki.asterisk.org/wiki/pages/viewpage.action?pageId=32375589

http://the-asterisk-book.com/1.6/call-file.html


#3

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


(Rom1906) #4

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 ?
Thanks


(TheWebMachine Networks (Sangoma Software Development Partner)) #5

In addition to AGI, there is also the Asterisk Manager Interface (AMI). You could look into using AJAM to enable AMI over HTTP:
https://wiki.asterisk.org/wiki/display/AST/Allow+Manager+Access+via+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.


(Rom1906) #7

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


(Communication Technologies) #8

@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: https://wiki.asterisk.org/wiki/pages/viewpage.action?pageId=32375589
Asterisk Manager Interface: https://wiki.asterisk.org/wiki/pages/viewpage.action?pageId=4817239
Asterisk Rest Interface: https://wiki.asterisk.org/wiki/pages/viewpage.action?pageId=29395573

See above.

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


(system) closed #9

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