P
P
parserya2015-08-31 15:12:06
Asterisk
parserya, 2015-08-31 15:12:06

How to get originate call duration in Asterisk?

Hello.
I implemented an outgoing call on the site using phpagi through the Originate method:

$actionID = md5($input_phone.$manager_phone.time()); // Уникальный ID
if ($asm->connect()) {
  $call = $asm->send_request('Originate',
        array(
        'Channel'=>"Local/".$manager_phone."@from-internal",
        'Context'=>'from-internal',
        'Exten'=>$input_phone,
        'Priority'=>'1',
        'Callerid'=>"%ID оператора%",
        'Async' => "yes",
        'ActionID' =>  $actionID
        ));
  $asm->disconnect();
}

Everything works - calls go. There was a need to get the duration of these calls. And this is where things got weird. I found the CoreShowChannels method in the documentation, to which you pass the ActionID and it allegedly returns the duration of the call. When I call this method while connecting via telnet, the results are:
Response: Success
ActionID: c78d1d8c43e9b14a
EventList: start
Message: Channels will follow

Event: CoreShowChannel
Duration: 00:16:57
...

However, when I make the same request via PHP, I only get the top part of the Array in response ( [Response] => Success [ActionID] => c78d1d8c43e9b14a [EventList] => start [Message] => Channels will follow )
Maybe after call send_request CoreShowChannels need to do some additional stuff to get the results of Events? Can anyone at least point me in the right direction?
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2015-08-31
@rostel

Catch Event: OriginateResponse

Action: login
Username: test
Secret: test
Events: on

Action: Originate
Channel: SIP/331
Application: Hangup
ActionID: adaff
Async: yes

Event: OriginateResponse
Privilege: call,all
ActionID: adaff
Response: Success
Channel: SIP/331-000003e0
Context: 
Exten: 
Reason: 4
Uniqueid: 1441039425.992
CallerIDNum: <unknown>
CallerIDName: <unknown>

It is sent when the channel specified in Channel responds
.
But most importantly, you get a Uniqueid, by which you can further connect with subsequent Events.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question