Runescape Haven

Your Runescape Help Site & Blog - Free Runescape Tips and Guides on all things Runescape

News Feed
What's This?
Home
About
Contact
Advertise
Topsite
Forums
Links
Runescape News
Runescape Tips
Runescape Clans
Runescape Pking
Runescape Cheats
Runescape Forums
Runescape Money Making

How to read Runescape highscores?

If you are wondering how to utilize the new Runescape highscores service provided by Jagex on your own site and don’t know where to start, then this article is for you. I will provide a sample PHP code which you can grab and reuse whenever you wish.

But before we start I’d like to give a little background for the issue. As you might be aware Jagex made a step toward fan sites recently by introducing a new programmatic way to access Runescape highscores. Previously, if you wanted to obtain highscores for a player you would have to go to the regular Runescape high scores page with lots of HTML and images, grab its content and parse. The code would look like something that ugly:

//———- PHP code to follow ————
$url = ‘http://hiscore.runescape.com/lang/en/aff/runescape/hiscorepersonal.ws?user1=’ . $user;
$rs_string = file_get_contents($url);
preg_match_all(’#<table cellpadding=”3″ cellspacing=”0″ border=0>(.*?)</table>#s’, $rs_string, $stats);
$score = $stats[1][0];
$score = strip_tags($score);
//—————- end of PHP code ————————

Yuck! Then you would also parse the resulting table and account for things not featured in high scores for different players.

But now you can simply go to something like this:
http://hiscore.runescape.com/index_l…?player=Vaskor
and get all the stats you need! Plus this way will get you information about 30+ stats even when they are not shown in the high scores! Truly awesome. You can replace the ugly code shown above with this much more elegant and useful one (which works faster as well):

//———- PHP code to follow ————-
$cats_for_rs = array(’Overall’, ‘Attack’, ‘Defence’, ‘Strength’, ‘Hitpoints’,
‘Ranged’, ‘Prayer’, ‘Magic’, ‘Cooking’, ‘Woodcutting’, ‘Fletching’, ‘Fishing’, ‘Firemaking’, ‘Crafting’, ‘Smithing’, ‘Mining’, ‘Herblore’, ‘Agility’, ‘Thieving’, ‘Slayer’, ‘Farming’, Runecraft’, ‘Hunter’, ‘Construction’);

$user = “Vaskor”;
$txt = file_get_contents(’http://hiscore.runescape.com/index_lite.ws?player=’.$user);

$score = array();

//explode using end of line as a delimiter
$data = explode (”\n”, $txt);

$ind = 0;
foreach ($data as $word) {
//key is a skill name
$key = $cats_for_rs[$ind];
//explode using a comma as a delimiter
$data_n = explode (”,”, $word);
$score[$key][”Rank”] = $data_n[0];
$score[$key][”Level”] = $data_n[1];
$score[$key][”Exp”] = $data_n[2];
$ind++;
}
//use level as a key for further processing as rank may be -1
//for 30+ stats not featured in high scores

//—————- end of PHP code ————————

That’s it. Easy and simple.

However, there is a catch…
If the user does not have ANY skills in the high scores Jagex service returns ‘Page not found’ error and it brakes the whole thing down! Ouch…

They should have returned data in the same format if a person is not in the high scores… Well, they don’t… So, if you ask me, the new high scores service has only limited usability. In some cases it cannot be used because of this limitation.
I sent a suggestion to Jagex to fix the service behavior, but no response was given back to me. So for the time being I personally still use the old and ugly parsing method at Runewise and make a secondary calls to the Jagex service only to fill gaps for 30+ non-high score skills. Alas.

But again, the new service can be used in many other cases and it is definitely a step forward. I look forward additional services from Jagex which would allow fan sites to provide better, richer experiences to the players.

Posted by vrunewise (owner of Runewise and Runescape Reader’s Digest)


Did You Enjoy this Post? Subscribe to Runescape Haven for Free Today!


1 Star2 Stars3 Stars4 Stars5 Stars (9 votes, average: 4.33 out of 5)
Loading ... Loading ...
9,560 Views



9 Responses to “How to read Runescape highscores?”

    vrunewise Says:

    One correction. A few days ago Jagex reduced amount of the information the highscores service returns (silent non-announced change). Now the service returns information identical to what you see in the regular highscores. So no more info about 30+ non-highscore skills.
    The code still works, just amount of data you get from it is less now.

    knifestorm Says:

    I just started to use this stuff. Couldn’t have done it without you. Thanks.

    - Runescape Haven Says:

    […] I wrote in the ‘How to read Runescape highscores?’ article, there is one API (Application Programming Interface). Specifically an API that allows […]

    External APIs for Runescape? Please… - Runescape Haven Says:

    […] I wrote in the ‘How to read Runescape highscores?’ article, there is one API (Application Programming Interface). Specifically an API that allows […]

    snowbell84 Says:

    runescape is amazin i just started a new account i played 3 years but my lvl 80 ac was haked any ideas hw 2 get em back
    i was in high scores on my old main
    mel xx

    Oveckin Says:

    Parse Error line 2? :-o

    Oveckin Says:

    sorry, problem is with PSPAD get ? instate ”

    THanks for code. :-)

    RunescapeGod Says:

    Thanks for the code

    RunescapeGod Says:

    I made a grand exchange code check it out at my website ;) click on my name

Comments

 
 
Join the RS Haven Newsletter Today!

Email Address:
 
Categories:

Last 10 Posts:

Archives:

Blogroll:

Meta:


 
 
 
Related Articles
Most Popular Articles
Top Rated Articles
Wild Removal really Needed? (5)
Runescape Keeps on Keeping On (5)
Has The New Trading Rules Ruined Team Monster Hunting? (5)
Decline in Runescape Money and Gold Industry (5)
Protecting Your Runescape Account from Hackers (4.88)
Q & A with Andrew Gower on Runescape Success (4.87)
How to manage your Miscellania Kingdom effectively (4.78)
Get Paid to Play Mechscape and be a Professional Gamer (4.77)
What is so good about Hunter skill? (4.76)
Was it worth it? (4.7)
Copyright Runescape Haven © 2007. All Rights Reserved.
Runescape is a Trademark of Jagex © 2000 - Runescape.com
Runescape Demoniknights Top 100 RuneCrypt WizzOnline Extreme Gamerz Z-100 Topsite Rune County Topsites RuneScape topsite RuneScape Top 200 Runetower Topsite