vestervang / rs-api
一个API,用于创建对所有Runescape API的接口
v1.0.5
2018-04-12 17:20 UTC
Requires
- php: >=7.1
- guzzlehttp/guzzle: ~6.0
Requires (Dev)
- phpunit/phpunit: ^7
This package is auto-updated.
Last update: 2024-09-29 04:37:14 UTC
README
核心代码来自 Burthorpe的runescape-api
安装
依赖关系
安装
composer require vestervang/rs-api
用法
Hiscore
require __DIR__.'/vendor/autoload.php'; use vestervang\rsApi\RS3\Hiscore; $hiscore = new Hiscore(); $username = 'zezima'; $stats = $hiscore->getStats($username)
如果您想遍历统计数据列表,可以这样做
for($i = 0; $i < $stats->getCount(); $i++){ $stat = $stats->getStat($i); echo 'Name: '. $stat->getSkill()->getName(). '<br>'; echo 'Rank: '. $stat->getRank(). '<br>'; echo 'Level: '. $stat->getLevel(). '<br>'; echo 'Xp: '. $stat->getExperience(). '<br>'; echo '<br><br>'; }
或者,如果您想使用foreach循环
foreach($stats->getStats() as $stat){ echo 'Name: '. $stat->getSkill()->getName(). '<br>'; echo 'Rank: '. $stat->getRank(). '<br>'; echo 'Level: '. $stat->getLevel(). '<br>'; echo 'Xp: '. $stat->getExperience(). '<br>'; echo '<br><br>'; }
GE
目前获取物品价格的唯一方式是通过查找ID然后使用它。
require __DIR__.'/vendor/autoload.php'; use vestervang\rsApi\RS3\GE; $api = new GE(); $item = $api->getItemById(4151);
我自行计算百分比差异,以获得更精确的数字,而不是API返回的+0.0%或-0.0%。
最佳怪物列表
在最佳怪物列表API中,有一个选项可以将API调用的结果保存到仓库中(结果将作为怪物对象保存到仓库)。
这可以在每次调用的基础上关闭。只需发送第二个参数为false,就不会在仓库中保存数据。
Id
require __DIR__.'/vendor/autoload.php'; $bestiary = new \vestervang\rsApi\RS3\Bestiary(); //This will save to the repo and returns the json $beast = $bestiary->getBeastById(49); //This call only returns the json $beast = $bestiary->getBeastById(49, false);
这将返回包含所有详细信息的怪物的JSON。
Name
require __DIR__.'/vendor/autoload.php'; $bestiary = new \vestervang\rsApi\RS3\Bestiary(); $beast = $bestiary->getBeastByName('cow');
这将返回包含名称和ID的怪物列表的JSON。
Level
require __DIR__.'/vendor/autoload.php'; $bestiary = new \vestervang\rsApi\RS3\Bestiary(); $beast = $bestiary->getBeastsByLevel('150-300');
这将返回包含名称和ID的怪物列表的JSON。
Letter
require __DIR__.'/vendor/autoload.php'; $bestiary = new \vestervang\rsApi\RS3\Bestiary(); $beast = $bestiary->getBeastsByLetter('y');
这将返回包含名称和ID的怪物列表的JSON。
Area
此函数区分大小写,'The Abyss'和'The abyss'将不会返回相同的结果。
require __DIR__.'/vendor/autoload.php'; $bestiary = new \vestervang\rsApi\RS3\Bestiary(); $beast = $bestiary->getBeastsByArea('The Abyss');
这将返回包含名称和ID的怪物列表的JSON。