Reputation: 1102
I'm trying to make a checker script to check if the IP asterisk have Asterisk Call Manager.
I did it by make php script and using curl - the result and the response was
Asterisk Call Manager/1.3
Response: Error
Message: Missing action in request
It's good for right now, it's expected.
The other expected is that I should send action in request as the massage said. So how can i send action like this:
action: login
user:admin
secret:admin
Upvotes: 0
Views: 2033
Reputation: 1
I built a click 2 call script in php and it working but I am not able to find a variable to be sent to AMI along the call file which should disconnect the call after a specific time. i.e. I want to set 5 minutes as a max window for any call to happen and in case call is still on asterisk should disconnect the call.
my code is: I am looking for a variable to be added along with socket which can disconnect the call if length is more than 5 minutes.
$oSocket = fsockopen($strHost, 5038, $errnum, $errdesc) or die("Connection to host failed");
fputs($oSocket, "Action: login\r\n");
fputs($oSocket, "Events: off\r\n");
fputs($oSocket, "Username: $strUser\r\n");
fputs($oSocket, "Secret: $strSecret\r\n\r\n");
fputs($oSocket, "Action: originate\r\n");
fputs($oSocket, "Channel: $strChannel\r\n");
fputs($oSocket, "WaitTime: $strWaitTime\r\n");
fputs($oSocket, "CallerId: $strCallerId\r\n");
fputs($oSocket, "Exten: $strExten\r\n");
fputs($oSocket, "Context: $strContext\r\n");
fputs($oSocket, "Priority: 1\r\n\r\n");
fputs($oSocket, "Action: Logoff\r\n\r\n");
sleep(3);
fclose($oSocket);
Upvotes: 0
Reputation: 15259
I highly recommend you use already writed library
For php that is phpagi libs.
http://phpagi.sourceforge.net/
In this example you not respect protocol. Protocol say have be Action.
http://www.voip-info.org/wiki/view/Asterisk+manager+API
Upvotes: 2