is it possible to initiate a call using php?
example…
thanks in advance
is it possible to initiate a call using php?
example…
thanks in advance
Yes … look into phpAGI or just use php to telnet into the asterisk AMI (asterisk manager interface)… for here look into the Action: Originate … all this can be found on at voip-info.org
hope that helps
can you please post a sample code here. i have no idea howto do it.
ive read the comments. the first comment is what exactly i wanna do.
thanks
sure…
again there are a few different ways to do this… so here are a few
phpAGI:
$asm = new AGI_AsteriskManager();
if($asm->connect($host,$user,$pass)) {
$res = $asm->Originate ($channel, $exten, $context, $priority, $application, $data, $timeout, $callerid, $variable, $account, $async, $actionid);
if ($res['Response'] == "Success") {
echo "Successfully originated a call";
}
$asm->disconnect();
}
Most options in the originate command are optional look at the voip-info.org website for details on which ones you need.
php fsocket:
$socket = @fsockopen($host, $port, $errno, $errstr);
if (!$socket) {
echo "$errstr ($errno)<br />\n";
} else {
$header = fgets($socket,4096);
$login = "Action: Login\r\n";
$login .= "Username: $user\r\n";
$login .= "Secret: $pass\r\n\r\n";
fwrite($socket, $login);
$response = trim(fgets($socket,4096));
$message = trim(fgets($socket,4096));
if(stristr($response,":") == ": Success") {
$action = "Action: Originate\r\n";
$action .= "Channel: Zap/g2/8135551212\r\n"
$action .= "Context: default\r\n";
$action .= "Exten: 101\r\n";
$action .= "Priority: 1\r\n";
$action .= "Callerid: 3125551212 \r\n\r\n";
/*
ADD ALL THE OTHER OPTIONS YOU MIGHT WANT
*/
fwrite($socket, $action);
$response = trim(fgets($socket,4096));
$message = trim(fgets($socket,4096));
echo "Just originated a call";
}
}
These are just examples and will not work for your setup as is… you need to alter the values of the originate command… but essentially that’s how it’s done… now these arn’t the most clean cut and error proof… and they dont check for failure but it’s a start
i cant connect to the server using the 5038/4569 port.
thanks
are you on the local host? if not check firewall… if so or there is no firewall check the server configuration settings… it’s in there somewhere
im in! i used the default port 5038.
theres a log coming in in asterisk CLI. im pretty close.
now how can i call an extension number?
here’s the cli log [quote]
== Parsing ‘/etc/asterisk/manager.conf’: Found
== Manager ‘test’ logged on from 10.0.0.80
== Manager ‘test’ logged off from 10.0.0.80
[/quote]
manager.conf
Check your PM…we’re moving it off board
oppss i edited the post…
do you have a YM ID?
do you know how to get the whole response messgae?
[quote]fwrite($socket, $action);
$response = trim(fgets($socket,4096));
$message = trim(fgets($socket,4096));
[/quote]
i can only display the first line… (e.i Response : Success)
You need to stick one of those in a while loop that loops until the response is a blank line … look at php.net or other php tutorials to learn how to do this