Hi there,
I'm trying to streamline some fetching of data that a site of mine does. Presently, every time the page is reloaded, data from another website (also mine, but on a different server) is sought and pulled into it. However, this can cause a great deal of delay on page loading, for various reasons (some obvious -- latency and such -- and some not so obvious).
What I'd like to do instead is to just use a cron job to pull data every x minutes and dump it into a server-side file, which would then be what was displayed on the site.
Pretty sure I know how to do the cron_tab part, but I don't think I've figured out how to have PHP write the HTML output to a file.
This is what I have right now:
<?php
//Grab data
$data = include_once("http://www.westeros.org/ASoIaF/News/");
$fp = fopen("temp_file.php", "w+");
fwrite($fp, $data);
fclose($fp);
?>
temp_file.php does get created if it exists, and I can write a simple text string, but obviously there's a problem with trying to dump in HTML output. I figure the problem has to do with line endings, but I have no idea how to convert the input to fit with what fwrite wants to do. Does PHP have any function to do that automatically, or is there some other approach I should be using?
Thanks!