Decoding and caching json every 60 minutes
Posted
by Gary
on Stack Overflow
See other posts from Stack Overflow
or by Gary
Published on 2010-05-29T22:26:20Z
Indexed on
2010/05/29
22:32 UTC
Read the original article
Hit count: 244
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.
© Stack Overflow or respective owner