[asterisk-users] AMI originate and PHP

Bruce Nik brucevoip at gmail.com
Wed Dec 23 17:19:54 CST 2009


Hi Guys,

I am trying to make a web form where a person is allowed to put in
$phoneNumber, $dialNumber, and $spoofNumber to make a call with spoof caller
ID. There are a few problems that I am facing with Asterisk AMI Originate
command. The reason why I want to use the darn AMI Originate is because I am
sending calls to mobile phones and I want to have some accountability and to
know if a call was connected for billing purposes or not. Calls go to PSTN
through SIP provider so all signaling is available.

First, if i use AMI Originate to dial both parties with the set CallerID
then, one party may pick up than the other and channel is not bridged at
ringing. So, this can confuse the callee. So, I thought I should send calls
to a context first and then ask customer enter $spoofNumber and then place
call but then I am facing another problem. Using that, the internal context
is called first and all announcements are made and then the
SIP/sipProvider/$phoneNumb is dialed. Or at least it's dialed at the same
time but since it takes time to pick ones phone context already goes over
it's announcement for putting in spoof number and dialnumber. Please guide
me how to do this properly. Following is the code and the context:

$sys_ip = "127.0.0.1";
$User_str = "test";
$Secret_str = "test";
$phoneNumb = "14167777777";
$dialNumb = "14168888888";
$spoofNumb = "1416999999";
$oSocket = fsockopen($sys_ip, 5038, $errnum, $errdesc) or die("Connection to
host failed");

fputs($oSocket, "Action: login\r\n");
fputs($oSocket, "Username: $User_str\r\n");
fputs($oSocket, "Secret: $Secret_str\r\n\r\n");
fputs($oSocket, "Events: off\r\n\r\n");
fputs($oSocket, "Action: originate\r\n");
fputs($oSocket, "Channel: SIP/testTrunk/$phoneNumb\r\n");
fputs($oSocket, "Exten: $dialNumb\r\n");
fputs($oSocket, "Context: testphp\r\n");
fputs($oSocket, "Priority: 1\r\n\r\n");
fputs($oSocket, "Timeout: 10000\r\n");
fputs($oSocket, "CallerId: $spoofNumb\r\n");
fputs($oSocket, "Async: true\r\n");
fputs($oSocket, "Action: Logoff\r\n\r\n");

fclose($oSocket);


/etc/asterisk/extensions.conf
[testphp]
exten => _X.,1,Answer()
exten =>
_X.,n,Playback(/var/lib/asterisk/sounds/please_enter_dialnumber_and_spoof_callerid)
exten => _X.,n,Read(dialnumber,,10)
exten => _X.,n,Read(spoofnumber,,10)
exten => _X.,n,Playback(connecting_now)
exten => _X.,n,Dial(SIP/testTrunk/$dialNumb)
exten => _X.,n,Hangup()

Thanks a lot.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20091223/01ccc195/attachment.htm 


More information about the asterisk-users mailing list