OriginateResponse event

Asterisk version :Asterisk 1.8.3.2
Asterisk Call Manager/1.1
Permissions for manager user:
read = all
write = all
I have been using a php script to originate calls via AMI and attempted to collect a “Reasons” to store them in data base.
This is part of my script:
fputs($socket, “Action: Login\r\n”);
fputs($socket, “UserName: $astuser\r\n”);
fputs($socket, “Secret: $astpass\r\n\r\n”);

fputs($socket, “Action: Originate\r\n”);
fputs($socket, “ActionID: $id\r\n”);
fputs($socket, “Channel: Local/$des\r\n”);
//fputs($socket, “Channel: $tech/$tru/$des\r\n”);
fputs($socket, “Context: $context\r\n”);
fputs($socket, “Exten: $num\r\n”);
fputs($socket, “Priority: 1\r\n”);
//fputs($socket, “Application: Dial\r\n”);
//fputs($socket, “Data: Local/$num\r\n”);
fputs($socket, “Timeout: $dur\r\n”);
fputs($socket, “CallerID: “$cli” <$cli>\r\n”);
fputs($socket, “Variable: CDUR=$cdur\r\n” );
fputs($socket, “Variable: ID=$id\r\n”);
fputs($socket, “Async: True\r\n\r\n”);

fputs($socket, “Action: WaitEvent\r\n”);
fputs($socket, “ActionID: $id\r\n” );
fputs($socket, “Timeout: $dur\r\n\r\n”);

fputs($socket, “Action: Logoff\r\n\r\n”);

and collected output almost always comes back with “Event: Newchannel” in place "OriginateResponse"
As you may see I attempted many different ways to call, but none of them did not produced consistent outputs of “OriginateResponse” .
Perhaps I am missing something?

I don’t believe WaitEvent serves any useful purpose here.

You need to read events until the one that matches the Originate returns.