Skip to content

Instantly share code, notes, and snippets.

@HostOnNet
Last active September 8, 2015 05:18
Show Gist options
  • Select an option

  • Save HostOnNet/f01831297ae22a5b6ba7 to your computer and use it in GitHub Desktop.

Select an option

Save HostOnNet/f01831297ae22a5b6ba7 to your computer and use it in GitHub Desktop.
<?php
$pageApi = file_get_contents_curl('http://services.runescape.com/m=itemdb_rs/api/catalogue/detail.json?item=29492');
$itemInfo = json_decode($pageApi, true);
echo "<pre>";
echo "Item Name: " . $itemInfo['item']['name'] . "\n";
echo "Item Price: " . $itemInfo['item']['current']['price'] . "\n";
echo "<hr>";
print_r($itemInfo);
function file_get_contents_curl($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment