I'm trying to read certain lines from a remote file being the code
// get bio from remote servers from line 835 to 859
$userbio = fopen("http://example.com/".$db->username, 'r');
$lineNo = 0;
$startLine = 865;
$endLine = 892;
while ($line = fgets($userbio)) {
$lineNo++;
if ($lineNo >= $startLine) {
echo $line;
}
if ($lineNo == $endLine) {
break;
}
}
fclose($userbio);
And this works great on a single php file, but when inside Wordpress all I get is Resource ID #164. Any other way of doing this remote read? thank you
Try file_get_contents() function, for guide visit w3school
You should use wp_remote_fopen()
:
Ref: https://codex.wordpress.org/Function_Reference/wp_remote_fopen