squegtech/steam-api 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

squegtech/steam-api

Composer 安装命令:

composer require squegtech/steam-api

包简介

PHP wrapper for the Steam web API

README 文档

README

PHPUnit

A PHP wrapper for the Steam API. Updated and maintained for the latest versions of PHP and Guzzle.

This package replaces https://github.com/DaMitchell/steam-api-php which has been abandoned.

All existing commands are based on this documentation: https://steamapi.xpaw.me/.

Installation

Install the latest version using Composer by running composer require squegtech/steam-api

Usage

<?php

include_once __DIR__ . '/../vendor/autoload.php';

use GuzzleHttp\Client;
use SquegTech\Steam\Command\Apps\GetAppList;
use SquegTech\Steam\Configuration;
use SquegTech\Steam\Runner\GuzzleRunner;
use SquegTech\Steam\Runner\DecodeJsonStringRunner;
use SquegTech\Steam\Steam;
use SquegTech\Steam\Utility\GuzzleUrlBuilder;

$steam = new Steam(new Configuration([
    Configuration::STEAM_KEY => '<insert steam key here>'
]));
$steam->addRunner(new GuzzleRunner(new Client(), new GuzzleUrlBuilder()));
$steam->addRunner(new DecodeJsonStringRunner());

/** @var array $result */
$result = $steam->run(new GetAppList());

var_dump($result);

Configuration

Two parameters can be passed to the Configuration object:

As shown above you can set the Steam API key by passing it into the Configuration constructor:

$steam = new Steam(new Configuration([
    Configuration::STEAM_KEY => '<insert steam key here>'
]));

Command

Commands are the classes that describe each endpoint. Each command implements SquegTech\Steam\Command\CommandInterface and has methods that will give the runners its interface, method, version, HTTP method and any parameters the endpoint requires.

The majority of commands are for GET endpoints. The POST endpoints are not fully implemented so please submit PRs for those you'd like to add.

Runners

Runners are simple objects that implement SquegTech\Steam\Runner\RunnerInterface. This interface has 3 methods with the most important being run. The other 2 are for setting the config object.

The run method has 2 arguments, $command and $result. $command is the endpoint you request on and $result is the result of the previous runner. This means that the $result of the first runner attached will be null.

Docker

This project comes with a Docker image and Docker Compose environment ready to run. Make sure to have both installed and start it with docker-compose up -d.

Once the Docker environment has started its command line can be accessed with docker-compose exec squegtech-steam-api bash.

Tests

Run the tests from the project root with docker-compose exec squegtech-steam-api vendor/phpunit/phpunit/phpunit outside of the Docker environment or vendor/phpunit/phpunit/phpunit inside of its bash shell.

统计信息

  • 总下载量: 4.47k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 0
  • Forks: 25
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-2-Clause
  • 更新时间: 2022-03-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固