I am connecting up to an API and as a result it should loop and output 5 iterations of the results from the checks.
The code
<?php
$i = 0;
$opts = array(
'https'=>array(
'method'=>"POST",
'header'=>"Accept-language: en\r\n" .
"Cookie: foo=bar\r\n"
)
);
$context = stream_context_create($opts);
$fp = fopen('https://ssl.theapidomain.com.au/check.php?domain=testdomain&suffixes=com.au', 'r', false, $context);
while ($i < 5) {
fpassthru($fp);
$out = explode('<br>', $fp);
echo $out[0];
echo "<br>";
echo $out[1];
echo "<br>";
echo date('H:i:s');
echo "<br>";
$i++;
}
fclose($fp);
?>
The output
available: testdomain.com.au not available: whoisfailure: Resource id #2
16:58:57
Resource id #2
16:58:57
Resource id #2
16:58:57
Resource id #2
16:58:57
Resource id #2
16:58:57
It should be outputting this 5 times:
available: testdomain.com.au not available: 16:58:57
It seems when I echo $out[0] and [2], it displays the resource id rather than the information inside (available / not available).