Learning PHP and AMI - Help returning Dial Status of SIP peer via AMI

Hi everyone,
I have a php that logs into the AMI, works to login and can successfully send commands.
However, I have not been successful in getting responses in a usable format. Many iterations of fget returns “Asterisk Call Manager/5.0.1” in this example. I would like to capture the peer status of “OK” before proceeding with other actions.

Anyone know how best to approach this?

Using FreePBX 14.0.11
Asterisk: 16

$host = "";
$user = "user2";
$secret = "HjsdfFF34765";

$tmout = 3;
// connection to manager open a socket and authenticate user defined in mamanger.conf
$sock = fsockopen($host,5038, $errno, $errstr, $tmout);
fputs($sock, "Action: Login\r\n");
fputs($sock, "UserName: $user\r\n");
fputs($sock, "Secret: $secret\r\n\r\n");
// AMI 
fputs($sock, "Action: SIPshowpeer\r\n");
fputs($sock, "Peer: 201\r\n\r\n");
//using general fgets($sock,128) just as a debug to echo the output for now
//would like to have the Value of Status returned, example - "OK"
echo $wrets;
fputs($sock, "Action: Logoff\r\n\r\n");