Hi all,
i’m trying to use the asterisk API to send a command.
I need to see how many users are online so, from the cli, the command ‘SIP SHOW PEERS’ shows:
Name/username Host Dyn Nat ACL Port Status
555004/555004 (Unspecified) D N 0 UNKNOWN
555002/555002 192.168.16.113 D N 41162 OK (113 ms)
555001/555001 (Unspecified) D N 0 UNKNOWN
Inside a simple php page i insered the code below:
$timeout = 10;
$asterisk_ip = “127.0.0.1”;
$socket = fsockopen($asterisk_ip,“5038”, $errno, $errstr, $timeout);
fputs($socket, “Action: login\r\n”);
fputs($socket, “Events: off\r\n”);
fputs($socket, “Username: admin\r\n”);
fputs($socket, “Secret: amp111\r\n\r\n”);
$wrets=fgets($socket,128);
echo $wrets;
fputs($socket, “Action: Command\r\n”);
fputs($socket, “Command: SIP SHOW PEERS\r\n”);
$wrets=fgets($socket,128);
echo $wrets;
fputs($socket, “Action: Logoff\r\n\r\n”);
fclose($socket);
on my php page i see:
Asterisk Call Manager/1.0 Response: Success
How to see the command result?
tnx