Skip to content

Instantly share code, notes, and snippets.

@Spea
Created April 27, 2015 19:39
Show Gist options
  • Save Spea/522156fb99f504d834cc to your computer and use it in GitHub Desktop.
Save Spea/522156fb99f504d834cc to your computer and use it in GitHub Desktop.
Get wow token price
<?php
$price = getTokenPrice();
function getTokenPrice($region = 'EU')
{
$filename = 'wowtoken.json';
if (file_exists($filename) && filemtime($filename) > time() - 1200) {
$content = file_get_contents($filename);
} else {
$content = file_get_contents('https://wowtoken.info/wowtoken.json');
file_put_contents($filename, $content);
}
$wowtoken = json_decode($content, true);
$updateInformation = $wowtoken['update'];
if (isset($updateInformation[$region])) {
return $updateInformation[$region]['raw']['buy'];
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment