定制 qstart-soft/steam-api 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

qstart-soft/steam-api

最新稳定版本:v1.0.1

Composer 安装命令:

composer require qstart-soft/steam-api

包简介

PHP library for working with Steam Web API

README 文档

README

Qstart Steam Api library contains all the necessary set of methods for requesting Steam Web API

Installation

$ composer require qstart-soft/steam-api

Getting Started

There are two ways to submit a request.

  1. Using a PSR-18 client instance
  2. On your own using your favorite library to send HTTP requests

First of all, we need to define the method for the request and create an instance of the method.

Each method for the api in the library is a class with properties-arguments.

First way

Let's send a request using the PSR-18 client:

use Qstart\SteamApi\SteamApiKey;
use Qstart\SteamApi\SteamApi;
use Qstart\SteamApi\Method\SteamApiGetOwnedGamesV1Method;

/** @var Psr\Http\Client\ClientInterface $client */

$key = new SteamApiKey('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');

$steamApi = new SteamApi($key, $client);

$method = new SteamApiGetOwnedGamesV1Method();
$method
    ->setSteamId(76561198072113884)
    ->setIncludeAppInfo(true)
    ->setIncludePlayedFreeGames(true)
    ->setAppIdsFilter([552990]);

/** @var \Psr\Http\Message\ResponseInterface $response */
$response = $steamApi->send($method);

// Json response from API
$json = $response->getBody()->getContents();
$data = json_encode($json, true);

Second way

Now consider the option with self-sending, without using PHP Standards Recommendations (PSR)

use Qstart\SteamApi\SteamApiKey;
use Qstart\SteamApi\SteamApiRequest;
use Qstart\SteamApi\Method\SteamApiGetOwnedGamesV1Method;

$key = new SteamApiKey('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
$method = new SteamApiGetOwnedGamesV1Method();
$method
    ->setSteamId(76561198072113884)
    ->setIncludeAppInfo(true)
    ->setIncludePlayedFreeGames(true)
    ->setAppIdsFilter([552990]);

$request = new SteamApiRequest($method, $key);

$link = $request->getUri();
$arguments = $request->getPreparedArguments();
$psr7Request = $request->getPsr7Request();

// Further, for example, if you want to get a link for a get request
$uri = $link . '?' . http_build_query($arguments);

Formats

In order to change the format of the response, you must call the setter of the method instance

use Qstart\SteamApi\SteamApiFormats;
use Qstart\SteamApi\Method\SteamApiGetOwnedGamesV1Method;

$method = new SteamApiGetOwnedGamesV1Method();
$method->setFormat(SteamApiFormats::VDF);

Wonderful!

Resources

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-10-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固