Fast and flexible SDK client of the Warface API in PHP.
Note that the "Weapon" branch is no longer a public API method. The International region API has also ceased to exist.
During technical weekly work on the game servers, the API may work unstable and give incorrect data.
Via Composer:
$ composer require wnull/warface-sdk guzzlehttp/guzzle:^7.3 http-interop/http-factory-guzzle:^1.0
We are decoupled from any HTTP messaging client with help by HTTPlug.
Structure of the client class constructor.
public function __construct(
\Wnull\Warface\HttpClient\ClientBuilder $httpClientBuilder = null,
\Wnull\Warface\Enum\RegionEnum $region = null,
): \Wnull\Warface\Client
Create an instance of the client using the following code:
$client = new \Wnull\Warface\Client();
When creating a builder, you can add custom plugins to it.
$builder = (new \Wnull\Warface\HttpClient\ClientBuilder());
$builder->addPlugin(
new class implements \Http\Client\Common\Plugin {
public function handleRequest(
\Psr\Http\Message\RequestInterface $request,
callable $next,
callable $first
): \Http\Promise\Promise {
// TODO: Implement handleRequest() method.
}
}
);
$client = new \Wnull\Warface\Client($builder);
By default, the CIS
region is set in the client. It can be changed to INTERNATIONAL
if necessary.
$builder = null; // builder or null
$client = new \Wnull\Warface\Client($builder, \Wnull\Warface\Enum\RegionEnum::INTERNATIONAL());
Thanks to HTTPlug, we support the use of many HTTP clients. For example, to use the Symfony HTTP Client, first install the client and PSR-7 implementation.
composer require wnull/warface-sdk symfony/http-client nyholm/psr7
Next, set up the Warface SDK client with this HTTP client:
$client = \Wnull\Warface\Client::createWithHttpClient(
new \Symfony\Component\HttpClient\HttplugClient()
);
Alternatively, you can inject an HTTP client through the Client
constructor.
The structure of the application is based solely on the public methods described in the official docs.
-
Method
catalog
returns a complete list of achievements available in the game, with their id and name.$catalog = (new \Wnull\Warface\Client())->achievement()->catalog();
-
Method
members
returns information about the clan.$members = (new \Wnull\Warface\Client())->clan()->members('<clan>');
-
Method
missions
returns detailed information about available missions and rewards for completing.$missions = (new \Wnull\Warface\Client())->game()->missions();
-
Method
monthly
returns the monthly rating.If the
$clan
parameter is used, the response from the server will contain data about the selected clan, it will also indicate exactly the league in which this clan is located even if it was not selected in the$league
.If only the
$league
parameter is used, the server will return the top 100 for that league.$monthly = (new \Wnull\Warface\Client()) ->rating() ->monthly('?<clan>', \Wnull\Warface\Enum\RatingLeague::ELITE(), '?<page>');
-
Method
clan
returns information about the rating of clans.$clan = (new \Wnull\Warface\Client())->rating()->clan();
-
Method
top100
returns a TOP-100 rating.If the parameter
$class
is not specified, the data gets for all classes.$top100 = (new \Wnull\Warface\Client())->rating()->top100(\Wnull\Warface\Enum\GameClass::MEDIC());
-
Method
stat
returns player statistics.$stat = (new \Wnull\Warface\Client())->user()->stat('<name>');
-
Method
achievements
returns player's achievements.$achievements = (new \Wnull\Warface\Client())->user()->achievements('<name>');
-
Method
catalog
returns a complete list of items available in the game, with their id and name.$catalog = (new \Wnull\Warface\Client())->achievement()->catalog();
$ composer test
The MIT License (MIT). Please see License File for more information.