Thanks David below i my complete code snippet.
I am calling the asterisk dial method from php script that is calling the customer no and once customer answered then it captured in the [phones-pd] context. my problem is that context [phones-pd] is getting called only when the customer answered.How can i captured if the customer is busy or rejected the call without answering.
php script
$oSocket = fsockopen ("$server_ip", 5038, &$errno, &$errstr, 20);
if (!$oSocket) {
echo “$errstr ($errno)
\n”;
} else {
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: DAHDI/g0/0’.Phoneno\r\n”);
fputs($oSocket, “WaitTime: 30\r\n”);
fputs($oSocket, “CallerId: $strCallerId\r\n”);
fputs($oSocket, “Exten: s\r\n”);
fputs($oSocket, “Context: phones-pd\r\n”);
fputs($oSocket, “Account: 123456\r\n”);
fputs($oSocket, “Priority: 1\r\n\r\n”);
fputs($oSocket, “Action: Logoff\r\n\r\n”);
sleep(2);
//fclose($oSocket);
}
asterisk code
[phones-pd]
exten => s,1,Answer()
exten => s,n,Set(starttime=${STRFTIME(${EPOCH},%Y-%m-%dT%H:%M:%S)})
exten => s,n,Queue(retainerspd,60)
exten => s,n,Hangup()
exten => h,1,Set(currenttime=${STRFTIME(${EPOCH},%Y-%m-%d %H:%M:%S)})
exten => h,n,Hungup()