Decoding and caching json every 60 minutes
- by Gary
Hi,
How do I do this on a php webpage?
I want to get and decode a json string and display the results as html on my page, however, I don't want it hotlinking back to the source.
If I could write the decoded string to a txt file say weather.txt on the server and keep the html formatting and do it so that the page won't fetch the json script until 60 minutes has passed since the last time it was fetched regardless of how many times the page is opened during that 60 minute period and the weather.txt is viewed.
All I can come up with is a simple script that hotlinks, everything else I have tried simply failed.
$file = file_get_contents('http://sample.com/weather');
$out = (json_decode($file));
echo $out-mainText;
Will appreciate any help with this.