I'm new about Asterisk, it's already installed and I have all host details, what I need is how to use Asterisk in my symfony2 web application; Someone have an idea or he worked on this before?
EDIT
Here is the list what I should do in my web application:
EDIT 1
I start by that small code in my controller :
use Pastum\Component\PAMI\Client\Client;
/* These are (in order) the options we can pass to PAMI client:
*
* The hostname or ip address where Asterisk AMI is listening
* The scheme can be tcp:// or tls://
* The port where Asterisk AMI is listening
* Username configured in manager.conf
* Password configured for the above user
* Connection timeout in milliseconds
* Read timeout in milliseconds
*/
$options = array(
'host' => '127.0.0.1',
'scheme' => 'tcp://',
'port' => 9999,
'username' => 'admin',
'secret' => 'mysecret',
'connect_timeout' => 10000,
'read_timeout' => 10000
);
$client = new Client($options);
// Open the connection
$client->open();
// Close the connection
$client->close();
But I do not know what I can do in the view page or after connection?
And how I can execute needs commands with code?!
I have used Asterisk in a Symfony Application. How We've done it:
The biggest problem for you will be how to transfer the sound, one way is to use flash.
Phone number validation - you will find a lot of solutions on GOOGLE.
More detailed instruction:
You'll need a Controller - that will handle your requests and call the service. For example you have to hangup a call, you need an action in your controller and an action in your service. In controller you init the service and call hangup action from service that will hangup call.
public function hangupAction(Request $request) { $asteriskService = // Get the asterisk service $asteriskService->hangup(); return new JsonReponse(); }
// Code from the service
public function hangup($agent) { fputs($this->getSocket(), "Action:Hangup\\r\\n"); fputs($this->getSocket(), "Channel:/^SIP/".$agent."-.*$/\\r\\n\\r\\n"); fclose($this->getSocket()); }
Please have a look at AGI , AMI and ARI interface. They are language/platform agnostics way to communicate/integrate with asterisk from external application.
There are some great PHP libraries for asterisk exists as well.
All of these libraries are available via composer. You can use it with Symfony2 just like other PHP packages.
You can try this bundle https://github.com/ryzhov/asterisk-bundle , but it connect through asterisk AMI interface (5038 tcp port) for request and event, not stasis.
code example here https://github.com/ryzhov/example-asterisk-ami
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.