PHPAGI (AMI): call + play file

hello all,
I have write a little script php for call a sip soft phone, and play a file.

require_once('/var/lib/asterisk/agi-bin/phpagi-2.14/phpagi.php');
require_once('/var/lib/asterisk/agi-bin/phpagi-2.14/phpagi-asmanager.php');

$hostM="localhost";
$userM="userPhp";
$passM="secretPhp";

// destination 
$number = '9250';
// File to play
$file="hello!";
$am = new AGI_AsteriskManager();
if($am->connect($hostM,$userM,$passM)){
 $am->send_request('Originate',array('Channel'=>"SIP/$number",application => "Playback",data => "$file",'Callerid'=>$number));
$am->disconnect();
}

It works, but if I change it for a pstn call (with a digium TDM400), the phone rings just a time.
Really the phone rings just the time of file duration (eg for audio files short the phone rings once, for files longer the phone rings a couple of time…)
It’s a very strange thing! …or no!? :neutral_face:
Can you suggest me any solutions?
follows the modified script

[...]
/ destination 
$number = '348XXXXX';
// File to play
$file="hello!";
$am = new AGI_AsteriskManager();
if($am->connect($hostM,$userM,$passM)){
$am->send_request('Originate', array('Channel'=>"Zap/1/$number",application => "Playback",data => "$file",'Callerid'=>$number));

$am->disconnect();

Thx

Hi alcool179,

Sorry, I can’t help you. Maybe you can help me ?
I’m looking for a way to ring a Cisco IPPhone, programatically.
I’ve been told it should be possible via a SIP call.
Your sample code seems to do almost what I want, but :blush: I’m not sure where it fits.
Would you be so kind to provide a bit more context, please ?

Greetings from Midi-Pyrénées, France

marc.assin

create php file (dial.php) with the follows text

#!/usr/local/bin/php -q

<?php

require_once('/var/lib/asterisk/agi-bin/phpagi-2.14/phpagi.php');
require_once('/var/lib/asterisk/agi-bin/phpagi-2.14/phpagi-asmanager.php');

$hostM="localhost";
$userM="userPhp";
$passM="secretPhp";

// destination
$number = '9250';
// File to play
$file="hello!";
$am = new AGI_AsteriskManager();
if($am->connect($hostM,$userM,$passM)){
$am->send_request('Originate',array('Channel'=>"SIP/$number",application => "Playback",data => "$file",'Callerid'=>$number));
$am->disconnect();
}

then from a shell run

php dial.php

NB: 9250 is your CISCO IP phone :smile:

Hi,

Sorry for the late news.
I first tried to to use the PHP and http_post approach to talk directly to the phone. I guess the thing works, as I’ve no error feedback, but the phone doesn’t ring. End of road :blush:

So, I’ll drop that approach and restart from scratch with your suggestion. As I’m null at AGI, it will be a pain …
I noticed that your script mentions

I don’t have this library on my Asterisk system, so I guess I should start by putting things in place.

Would you have the patience to list the steps needed to update my installation in order to run PHP scripts ?

Thank you in advance