gameserverapp/php-api-wrapper

官方 GameserverApp.com API 包装器

0.1 2019-12-03 13:30 UTC

This package is auto-updated.

Last update: 2024-09-25 10:10:45 UTC


README

API 包装器可用于快速从 GameserverApp.com API 加载数据。您可以使用您的 客户端 ID客户端密钥 连接到 API,这些可以在您的 API 页面上找到:https://dash.gameserverapp.com/configure/api

API 有限制请求频率,这意味着您每分钟只能进行一定数量的调用。如果您调用过多,您的 API 密钥可能会(暂时)被禁用。在设计应用程序时请考虑这一点。例如,将您从 API 中获取的数据保存到数据库或缓存一段时间内的输出。

此 API 包装器允许您执行社区网站上提供的所有操作。某些功能(尚未)实现。

支持

如果您有任何疑问,请联系 support@gameserverapp.com

安装

通过 Composer

composer require gameserverapp/php-api-wrapper

require 'vendor/autoload.php';
$api = new GameserverApp\ApiWrapper\GSAClient('<api key>','<secret>');

不使用 Composer

作为替代,您可以将 API 包装器包含在您的当前网站中。请将代码从文件 `` 复制/粘贴到您的项目中。之后,请确保在您的代码中包含该文件。

include('path/to/GSAClient.php');
$api = new GSAClient('<api key>','<secret>');

用法

获取所有具有网站名称且连接到您域的服务器

$api->servers();

响应示例

[
  {
    "id":132056,
    "name":"RUST",
    "cluster_name":"Self-hosted cluster",
    "selfhosted":0,
    "p2p":0,
    "twitch_sub_only":false,
    "app_id":"252490",
    "game":{
      "name":"RUST",
      "icon":"http:\/\/dash.gameserverapp.com\/img\/games\/rust.png",
      "steam":{
        "client_id":"252490",
        "server_id":"258550"
      },
      "support":{
        "delivery":false,
        "level":false,
        "gender":false
      }
    }
  }
]

可用方法

域名

$api->domainSettings();
 
$api->domainStat('hours-played');

domainStat 选项

  • hours-played(图形)
  • online-players(图形)
  • new-characters(图形)
  • online-count-last-7-days(图形)
  • hours-played-last-7-days(图形)
  • new-players-last-7-days(图形)
  • active-tribes(组对象)
  • newbies(角色对象)
  • top-players(角色对象)
  • last-online(角色对象)

集群

$api->clusterStat('newbies');

clusterStat 选项

  • online-count-last-7-days(图形)
  • hours-played-last-7-days(图形)
  • new-players-last-7-days(图形)
  • active-tribes(组对象)
  • newbies(角色对象)
  • top-players(角色对象)
  • last-online(角色对象)

服务器

$api->serverStat(132056, 'top-players');

$api->servers();

serverStat 选项

  • online-count-last-7-days(图形)
  • hours-played-last-7-days(图形)
  • new-players-last-7-days(图形)
  • active-tribes(组对象)
  • newbies(角色对象)
  • top-players(角色对象)
  • last-online(角色对象)

$api->group('00c666f6-d521-47ce-88f9-6ca36451bda0');
$api->groupStat('00c666f6-d521-47ce-88f9-6ca36451bda0', 'hours-played');

$api->groups();

groupStat 选项

  • hours-played
  • levels-gained
  • xp-gained

用户

$api->user('6c4de76f-3df4-4b75-85a0-b4557c3f3564');
$api->userStat('6c4de76f-3df4-4b75-85a0-b4557c3f3564', 'levels-gained');

$api->users();

userStat 选项

  • hours-played
  • levels-gained
  • xp-gained

角色

$api->character('d1f6e8d1-0265-43ad-947e-c6bebe3343ee');
$api->characterStat('d1f6e8d1-0265-43ad-947e-c6bebe3343ee', 'xp-gained');

$api->characters();
$api->topCharacters();
$api->freshCharacters();
$api->onlineCharacters();
$api->spotlightCharacters();

characterStat 选项

  • hours-played
  • levels-gained
  • xp-gained