sync667/steam-web-api2

一个包装库,允许您使用PHP语言发送请求到Steam Web API

2.0.0 2015-12-10 18:30 UTC

This package is auto-updated.

Last update: 2024-08-26 22:07:02 UTC


README

版本将由我更新到新的Web API。

一个包装库,允许您使用PHP Laravel框架发送请求到Steam Web API。

这个库简单地将方法调用中的参数提取出来,并使用GuzzleHttp发送请求到Steam Web API,并以预期的格式返回响应。

它需要至少PHP 5.6版本。

安装

您可以通过Composer轻松安装此包

  • "sync667/steam-web-api2": "2.*"添加到您的composer.json文件中。
{
   "require": {
		"sync667/steam-web-api2": "2.*"
	    }
}
  • 在终端中输入composer update

  • 即可使用!

## 使用

  • 将以下命名空间添加到您的文件中
 use sync667\SteamWebApi\Api\AbstractSteamAPI;
  • 然后,您需要使用您的Steam Web API凭证初始化客户端
 AbstractSteamAPI::init('https://api.steampowered.com', 'YOUR_API_KEY', 'YOUR_RESPONSE_FORMAT');

注意:响应格式可以是json或xml。

  • 初始化后,选择您的API模块,然后调用相应的方法。

例如,如果我们想获取玩家物品,以下代码块将适合此目的

  $appID = ApplicationIDs::TeamFortress2;
  $steamID = 76561197962033671;
  $response = IEconItemsAPI::getPlayerItems($appID, $steamID);
  var_dump($response);

关于库的更多信息

  • 如您所知,Steam Web API有一些模块。这些模块在这个库中都是可用的。

以下是您可以使用的方法名称和命名空间列表。

 ISteamApps => 'Epigra\SteamWebApi\Api\ISteamApps'
 ISteamEconomy => 'Epigra\SteamWebApi\Api\ISteamEconomy' 
 ISteamNews => 'Epigra\SteamWebApi\Api\ISteamNews'
 ISteamRemoteStorage => 'Epigra\SteamWebApi\Api\ISteamRemoteStorage'
 ISteamUser => 'Epigra\SteamWebApi\Api\ISteamUser'
 ISteamUserStats => 'Epigra\SteamWebApi\Api\ISteamUserStats'
 IPlayerService => 'Epigra\SteamWebApi\Api\IPlayerService'
 ISteamWebAPIUtil => 'Epigra\SteamWebApi\Api\ISteamWebAPIUtil'
 IEconItems => 'Epigra\SteamWebApi\Api\IEconItems'
  • 另一方面,一些API调用需要应用ID。您可以通过Epigra\SteamWebApi\Constants命名空间下的ApplicationIDs类使用Steam应用ID。

库提供的应用及其ID列表

  CounterStrikeBeta = 260; 
  CounterStrikeGlobalOffensiveBeta = 710;
  TeamFortress2 = 440;
  TeamFortress2PublicBeta = 520;
  Dota2 = 570;
  Dota2InternalTest = 620;
  Dota2Beta = 205790;
  Portal2 = 620;
  Portal2Beta = 841;

例如,您可以轻松获取TeamFortress2 ID,如下所示

  ApplicationIDs::TeamFortress2;
  • 这个库有良好的文档,可以从docs/目录访问。

  • 更多信息请访问Steam页面

许可协议

 Copyright 2014 Epigra
 Updated 2015 sync667

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

    https://apache.ac.cn/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.