There are actually two ways to go about it. The first is to run a PHP script which creates a .call file in /var/spool/asterisk/outbound (if this is still the spool directory) with the following information:
Channel: IAX2/[insert context]/[insert phone number to call]
Callerid: [insert your caller ID]
MaxRetries: 5 ; Maximum number of times to redial
RetryTime: 30 ; Time to wait between redials
Context: [context in extensions.conf to use]
Extension: [extension in context]
It is HIGHLY recommended not to create the .call file directly in the spool directory, as Asterisk will try to read it before your’ve finished writing it. Instead, create it somewhere else, then MV it to the spool directory (not copy either, same problem as above).
The second option is to enable the Manager commands, set up a username and password and open up Asterisk on a port and enable 127.0.0.1 for the user.
Then, you can open a connection to the socket via
fsockopen(“127.0.0.1”, [port number])
and use fputs commands to write information. You’ll need to send the login information:
Each line seperated by an \r\n and a double \r\n to end the command.
Finally, the for the second option you can use the Originate command:
And send the same information that you would put into the .call file above, again, each line seperated by an \r\n and finish the command with a double \r\n.
Hope this helps