nightshade53 Posted May 13, 2009 Share Posted May 13, 2009 Hey, I'm designing a drop logger PHP page, and I wish for it to be able to retrieve the GE prices. Does anybody know how I can attempt this? :o ~Kray Link to comment Share on other sites More sharing options...
dsavi Posted May 13, 2009 Share Posted May 13, 2009 Well, the first thing that comes to mind is to cURL them and use simpleXML, but I seem to remember that the URLs change or something, making that difficult... Also there is no light version of the GE. Link to comment Share on other sites More sharing options...
MageUK Posted May 13, 2009 Share Posted May 13, 2009 It's fairly easy, you just need to know the ID of the item you want to grab... // Enter your item ID here. $itemid = 10392; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, "http://itemdb-rs.runescape.com/viewitem.ws?obj=".$itemid); curl_setopt($curl, CURLOPT_BINARYTRANSFER, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 3); curl_setopt($curl, CURLOPT_TIMEOUT, 6); $fullge = curl_exec($curl); $curl_http = curl_getinfo($curl, CURLINFO_HTTP_CODE); curl_close($curl); if ($curl_http == "404") { // For some reason Jagex has deleted the GE :D // Do whatever you need to here. } if (strpos($fullge, "The item you were trying to view could not be found.") !== FALSE) { // The item doesn't exist. // Do whatever you need to here. } ereg('Minimum price: ([0-9\.km,]+)', $fullge, $regex['minprice']); ereg('Market price: ([0-9\.km,]+)', $fullge, $regex['markprice']); ereg('Maximum price: ([0-9\.km,]+)', $fullge, $regex['maxprice']); /* * Element [1] of the $regex arrays now contains the prices from the GE. * Running them through trim() first is a good idea just to be safe. * */ // Just to prove it works! print_r($regex); Obviously that can very easily be turned into a function to grab the data for a given item ID. Link to comment Share on other sites More sharing options...
nightshade53 Posted May 13, 2009 Author Share Posted May 13, 2009 Perfect, thanks :) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now