From e6b60c4420112324d8b109967f69f864112433dc Mon Sep 17 00:00:00 2001 From: Eli Silakov Date: Sat, 14 Mar 2020 20:36:30 +0300 Subject: [PATCH] update to 18.0.0 --- ENDPOINTS.md | 13 +++++++++++ README.md | 10 ++++++-- simple_opendota.php | 56 ++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 71 insertions(+), 8 deletions(-) diff --git a/ENDPOINTS.md b/ENDPOINTS.md index 5ae0425..9bbc403 100644 --- a/ENDPOINTS.md +++ b/ENDPOINTS.md @@ -14,6 +14,7 @@ API Endpoint | Function | Parameters API Endpoint | Function | Parameters -- | -- | -- +`GET /playersByRank` | `playersByRank()` | `GET /players/{account_id}` | `player($player_id)` | `$player_id (int) = {account_id}` `GET /players/{account_id}/wl` | `player_winloss($player_id [, $params])` | `$player_id (int) = {account_id}`, `$params` `GET /players/{account_id}/recentMatches` | `player_recent_matches($player_id)` | `$player_id (int) = {account_id}` @@ -48,6 +49,12 @@ API Endpoint | Function | Parameters -- | -- | -- `GET /publicMatches` | `public_matches([$less_than_match_id])` | `$less_than_match_id (int) = less_than_match_id` - Get matches with a match ID lower than this value; null = not set (default) +### Parsed Matches + +API Endpoint | Function | Parameters +-- | -- | -- +`GET /parsedMatches` | `parsed_matches([$less_than_match_id])` | `$less_than_match_id (int) = less_than_match_id` - Get matches with a match ID lower than this value; null = not set (default) + ### Explorer API Endpoint | Function | Parameters @@ -174,6 +181,12 @@ API Endpoint | Function | Parameters -- | -- | -- `GET /admin/apiMetrics` | `api_metrics()` | none +### Constants + +API Endpoint | Function | Parameters +-- | -- | -- +`GET /constants/{resource}` | `constants()` | `$resource (string) = {resource}` - Resource name e.g. `heroes` + ### Find Matches API Endpoint | Function | Parameters diff --git a/README.md b/README.md index 165b330..9618af7 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,14 @@ # Simple OpenDota API library for PHP -### API version: 17.7.0 +### API version: 18.0.0 -Simple OpenDota API support realization for PHP. +Simple OpenDota API support for PHP. + +Handles API cooldown (to not get banned), API key usage, usage of various instances of OpenDota, Cli reporting. + +It's sync only version with weird methods naming. It's intended to be used for **simple** PHP scripts (cli ones in the first place). For Async version made for ReactPHP look for reactive-opendota-php. + +Note: It doesn't have an implementation for /feed endpoint. The endpoint tends to be unstable and it also requires HTTP streams support which doesn't work well with sync PHP. ## Requirements diff --git a/simple_opendota.php b/simple_opendota.php index f7161a3..5df253c 100644 --- a/simple_opendota.php +++ b/simple_opendota.php @@ -246,6 +246,18 @@ public function match($match_id, $mode = 0) { return $this->request("matches/".$match_id, $mode); } + // ********** Players By Rank + + /** + * GET /playersByRank + * Players ordered by rank/medal tier + * + * @return mixed $result List of players [ account_id, rank_tier, fh_unavailable ] + */ + public function playersByRank($mode = 0) { + return $this->request("playersByRank", $mode); + } + // ********** Players /** @@ -511,6 +523,26 @@ public function public_matches($less_than_match_id = null, $sort = 0, $mode = 0) return $this->request("publicMatches", $mode, $params); } + // ********** Parsed Matches + + /** + * GET /parsedMatches + * Get list of randomly sampled public matches + * + * @param int $less_than_match_id = null Get matches with a match ID lower than this value + * @param int $mode = 0 Fast mode flag (skip requests if cooldown or wait for API) + * + * @return mixed $result + */ + public function parsed_matches($less_than_match_id = null, $mode = 0) { + $params = []; + + if ( $less_than_match_id !== null ) + $params['less_than_match_id'] = (int)$less_than_match_id; + + return $this->request("parsedMatches", $mode, $params); + } + // ********* Explorer /** @@ -564,20 +596,16 @@ public function distributions($mode = 0) { * Search players by personaname * * @param string $request Search query string - * @param float $similarity = 0.51 Minimum similarity treshold, between 0 and 1 * @param int $mode = 0 Fast mode flag (skip requests if cooldown or wait for API) * * @return mixed $result */ - public function search($request, $similarity=0.51, $mode = 0) { + public function search($request, $mode = 0) { $params = []; if ( empty($request) ) return \false; - if ( $similarity != 0.51 ) - $params['similarity'] = (float) $similarity; - $params['q'] = $request; return $this->request("search", $mode, $params); @@ -726,7 +754,7 @@ public function hero_durations($hero_id, $mode = 0) { return $this->request("heroes/".((int)$hero_id)."/durations", $mode); } -/** + /** * GET /heroes/{hero_id}/players * Get players who have played this hero * @@ -966,6 +994,22 @@ public function find_matches($teams, $mode = 0) { return $this->request("findMatches", $mode, $teams); } + // ********** Constants + + /** + * GET /constants + * Get static game data mirrored from the dotaconstants repository + * Resources: https://github.com/odota/dotaconstants/tree/master/build + * + * @param string $resource Resource name e.g. heroes + * @param int $mode = 0 Fast mode flag (skip requests if cooldown or wait for API) + * + * @return mixed $result + */ + public function constants($resource, $mode = 0) { + return $this->request("constants/".$resource, $mode); + } + // ********** Feed /**