项目作者: ricardoboss

项目描述 :
PHP wrapper for the PUBG Tracker API
高级语言: PHP
项目地址: git://github.com/ricardoboss/PHPUBG.git
创建时间: 2017-08-04T17:07:03Z
项目社区:https://github.com/ricardoboss/PHPUBG

开源协议:MIT License

下载


PHPUBG

Test Status

PHP wrapper for the PUBG Tracker API.

Installation

PHPUBG is available on packagist, so you can easily require it via composer:

  1. composer require mcmainiac/phpubg

To use this as a standalone library (without composer), download the repository and extract it somewhere (preferably in your projects libraries folder) and set up an autoloader to load all files dynamically.
The root namespace of this library is \PHPUBG.

Usage

To get your own api key, please visit pubgtracker.com/site-api.

Assuming you are at the root of your project (the vendor folder is within your current folder):

  1. <?php
  2. require __DIR__ . "/vendor/autoload.php";
  3. use PHPUBG\Region;
  4. use PHPUBG\PubgBuilder;
  5. $statsEurope = PubgBuilder::setApiKey("your-api-key")
  6. ->getPlayer("MCMainiac")
  7. ->getStats(
  8. Region::get(Region::EUROPE)
  9. );
  10. var_dump($statsEurope);

This should dump all stats available for the player “MCMainiac” in the region “Europe”.

You can also use the Steam Id (a 64 bit number) instead of the username. PHPUBG will automatically resolve the username and get the stats:

  1. <?php
  2. $builder = PubgBuilder::setApiKey("your-api-key");
  3. $playerByName = $builder->getPlayer("MCMainiac");
  4. $playerBySteamId = $builder->getPlayer(76561198128415640); // steam id for "MCMainiac"
  5. // At this point $playerByName and $playerBySteamId are equivalent entities.
  6. $playerByName->getNickname() == $playerBySteamID->getNickname(); // will return true

If you want to apply another filter, just pass it to the getStats method:

  1. $player->getStats($region, $season, $mode);

whereas:

  • $region is an instance from the \PHPUBG\Region class or null
  • $season is an instance from the \PHPUBG\Season class or null
  • $mode is an instance from the \PHPUBG\matches\MatchMode class or null

If any variable of the above is null, then any value for this filter is accepted.

Example: You want to get all stats for the region “Europe” and the match mode “Solo”:

  1. $region = Region::get(Region::EUROPE);
  2. $mode = MatchMode::get(MatchMode::SOLO);
  3. $europeSoloStats = $player->getStats($region, null, $mode);

Development

Feel free to clone the repository, make your changes and open a pull request.

Please report issues right here on GitHub using the issues system.

Notes

When requesting stats, please keep the number of requests at ~1/sec.

Thanks to pubgtracker.com for their public api.

Thanks to all contributors!

Support on Beerpay

Hey dude! Help me out for a couple of :beers:!

Beerpay Beerpay