PHP code example of bert-w / runescape-hiscores-api

1. Go to this page and download the library: Download bert-w/runescape-hiscores-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bert-w / runescape-hiscores-api example snippets


// OSRS
$hiscores = new \BertW\RunescapeHiscoresApi\OSRSHiscores([
    'headers' => [
        'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36',
    ],
]);
// RS3
$hiscores = new \BertW\RunescapeHiscoresApi\RS3Hiscores([
    'headers' => [
        'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36',
    ],
]);

$player = $hiscores->player('someplayer');

$totalLevel = $player->totalLevel();
// Returns (int).

$skills = $player->skills();

// Only available for OSRS:
$minigames = $player->minigames();

// Case insensitive skill or minigame search. To be certain, use the
// exact name as used on the OSRS Hiscores page.
$player->get('agility')->level;
$player->get('Clue Scrolls (all)')->rank;
// Returns a \BertW\RunescapeHiscoresApi\HiscoreRow object.

$player->get('Overall')->level;
$player->get('Attack')->level;
$player->get('Defence')->level;
$player->get('Strength')->level;
$player->get('Hitpoints')->level; // (differs from RS3 "Constitution")
$player->get('Ranged')->level;
$player->get('Prayer')->level;
$player->get('Magic')->level;
$player->get('Cooking')->level;
$player->get('Woodcutting')->level;
$player->get('Fletching')->level;
$player->get('Fishing')->level;
$player->get('Firemaking')->level;
$player->get('Crafting')->level;
$player->get('Smithing')->level;
$player->get('Mining')->level;
$player->get('Herblore')->level;
$player->get('Agility')->level;
$player->get('Thieving')->level;
$player->get('Slayer')->level;
$player->get('Farming')->level;
$player->get('Runecraft')->level; // (differs from RS3 "Runecrafting")
$player->get('Hunter')->level;
$player->get('Construction')->level;

$player->get('Overall')->level;
$player->get('Attack')->level;
$player->get('Defence')->level;
$player->get('Strength')->level;
$player->get('Constitution')->level; // (differs from OSRS "Hitpoints")
$player->get('Ranged')->level;
$player->get('Prayer')->level;
$player->get('Magic')->level;
$player->get('Cooking')->level;
$player->get('Woodcutting')->level;
$player->get('Fletching')->level;
$player->get('Fishing')->level;
$player->get('Firemaking')->level;
$player->get('Crafting')->level;
$player->get('Smithing')->level;
$player->get('Mining')->level;
$player->get('Herblore')->level;
$player->get('Agility')->level;
$player->get('Thieving')->level;
$player->get('Slayer')->level;
$player->get('Farming')->level;
$player->get('Runecrafting')->level; // (differs from OSRS "Runecraft")
$player->get('Hunter')->level;
$player->get('Construction')->level;
$player->get('Summoning')->level;
$player->get('Dungeoneering')->level;
$player->get('Divination')->level;
$player->get('Invention')->level;
$player->get('Archaeology')->level;