PHP code example of qstart-soft / steam-api

1. Go to this page and download the library: Download qstart-soft/steam-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

qstart-soft / steam-api example snippets



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);



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);



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

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