Using PHPAGI script

Hello All,

    I am new to this forum and want to know that how we can use phpagi script to place calls from asterisk and play a prerecorded message to the called party (reciever end).

I have an asterisk server running with two trunks and extensions configured on it.

I had also downloaded the phpagi scripts named phpagi.php, phpagi-asmanager.php, phpagi-fastagi.php and mkdocs.php.

but didn’t found some help to start the coding to work.
Any help will be appreciated and thanks in advance

Ether

Hi ether,

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]
Priority: 1

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:

Action: login
Username: username
Secret: password

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:

Action: Originate

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 :smile:

ether,
First need to have a knowledge of what AGI does and how it does it.
Would recommend to read the wiki for AGI information and visit the
links mentioned before starting to create apps.
voip-info.org/wiki-Asterisk+AGI

Hello

Thanks for the help also I had already read that article. Now I can able to make the call from manager API but still not from .call file. This gives the error in Asterisk log “Permission Denied, Delete .call file”.

The other thing is that I want to get the details of that call which I made from coding means (billing seconds, destination number and status of call etc.).

Is it possible to get these details from manager API?
If yes then how it is possible.

Thanks in advanse for the help

Ether