mtoldfield Posted August 2, 2007 Share Posted August 2, 2007 Hello. I am trying to make a statistic signature for a game called RuneScape, in which will take the users statistics from the game's hiscore page. Recently, a new version for webmasters has been released, in which is just a very very basic output for people to parse and do what they like with it. I had trouble trying to connect to the page, as it's not something I've had the need to do before, and I was suggested by someone to use either sockets or cURL. Sockets really confused me, and cURL appears to be exactly what I'm looking for, but how it works is a mystery to me. This is the code I have, after reading some function lists, cURL guides, etc: <?php ob_start(); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://hiscore.runescape.com/index_lite.ws?player=" . $_GET['name']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $output = curl_exec($ch); print $output; // Test it works before actually doing anything else... curl_close($ch); ob_end_flush(); ?> Nothing happens. I've tried getting it to just print it straight off without me telling it to do anything else (So basically not putting it in a variable, and not having the RETURNTRANSFER that I read I should have), and nothing happens. The $_GET['name'] value is "lostwallaby", so it is supposed to be retrieving http://hiscore.runescape.com/index_lite.ws?player=lostwallaby, which when visiting in my browser, works fine. I've tried many different things, and nothing works. I thought it might be no cURL library on my server, so I tried another server, and it doesn't like curl_init(), as it is an unidentified function, so I therefore ruled out this conclusion. Does anyone have any ideas? Quote Link to comment Share on other sites More sharing options...
NArc0t1c Posted August 2, 2007 Share Posted August 2, 2007 Try this: <?php $URL = "http://hiscore.runescape.com/index_lite.ws?player=" . $_GET['player']; $ch = curl_init($URL); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); ?> Quote Link to comment Share on other sites More sharing options...
mtoldfield Posted August 2, 2007 Author Share Posted August 2, 2007 Thank you, however, it still only displays a blank page when I try that. It appears that after I have declared... $ch = curl_init($url); ...Nothing is printable. I placed a line, print 'Test';, on every line between every line of code, and nothing printed, unless it was before $ch. Quote Link to comment Share on other sites More sharing options...
DeadEvil Posted August 2, 2007 Share Posted August 2, 2007 you can use file_get_contents function file_get_contents(http://hiscore.runescape.com/index_lite.ws?player=". $_GET['name']); Quote Link to comment Share on other sites More sharing options...
HaLo2FrEeEk Posted August 2, 2007 Share Posted August 2, 2007 Or you can use the snoopy library, it is a collection of pre-written cURL functions that are so simple to call up, it almost seems like cheating. Look it up on google, "php snoopy library", I use it and it's great, saves the text of the page that you can call up by url, this is the syntax: <?php include('snoopy.php'); $snoopy = new Snoopy; $snoopy->fetch("URL"); $text = $snoopy->results(); ?> $text would contain the returned source code from URL, it's really nice. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.