Php ami

I am trying to write a small app to list my conference rooms. My test app is as follows.

[code]<?php
$timeout=15;
$socket = fsockopen(“127.0.0.1”,“5038”, $errno, $errstr, $timeout);
fputs($socket, “Action: Login\r\n”);
fputs($socket, “UserName: admin\r\n”);
fputs($socket, “Secret: password\r\n\r\n”);

fputs($socket, “Action: ConfbridgeListRooms\r\n\r\n”);

$wrets = fgets($socket);

echo $wrets;

fclose($socket);
?>[/code]

All I get back is
Asterisk Call Manager/1.3

I would Expect to see something like:

Asterisk Call Manager/1.3

Response: Success
EventList: start
Message: Confbridge conferences will follow

Event: ConfbridgeListRooms
Conference: 6300
Parties: 1
Marked: 0
Locked: No

Event: ConfbridgeListRoomsComplete
EventList: Complete
ListItems: 1

Ok, Figured it out so I am sharing

[code]<?php
$timeout=15;
$socket = fsockopen(“162.249.2.68”,“5038”, $errno, $errstr, $timeout);
fputs($socket, “Action: Login\r\n”);
fputs($socket, “UserName: user\r\n”);
fputs($socket, “Secret: password\r\n\r\n”);

fputs($socket, “Action: ConfbridgeList\r\n”);
fputs($socket, “ActionID: 1\r\n”);
fputs($socket, “Conference: 6300\r\n\r\n”);
fputs($socket, “Action: Logoff\r\n\r\n”);

$wrets=’’;
while (!feof($socket)) {
$wrets .= fread($socket, 8192);
$wrets .="";
}
fclose($socket);

echo $wrets;

?>[/code]

needed to add the

and

$wrets=''; while (!feof($socket)) { $wrets .= fread($socket, 8192); $wrets .="</br>"; }
Hope this helps the next guy!

Thanks for sharing :bulb:, fgets() Gets line from file pointer open by fsockopen() and do the trick