Skip to content

Instantly share code, notes, and snippets.

@whyisjake
Forked from moskowite/gist:1597357
Created January 11, 2012 23:07
Show Gist options
  • Save whyisjake/1597364 to your computer and use it in GitHub Desktop.
Save whyisjake/1597364 to your computer and use it in GitHub Desktop.
// 60 seconds * 60 minutes * 24 hours = 1 day refresh
$refreshInterval = 60*60*24;
$input = range(1,30);
$arr = array_rand($input, 4);
if ( false === ( $featured_products = get_transient( 'featured_products' ) ) ) {
// It wasn't there, so regenerate the data and save the transient
$request_url = 'http://makershed.com/net/webservice.aspx?api_name=generic\featured_products';
$xml = simplexml_load_file($request_url);
set_transient('featured_products', $xml, $refreshInterval );
}
$featured_products = $xml->Product;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment