<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bluepsyduck / factorio-mod-portal-client example snippets
use BluePsyduck\FactorioModPortalClient\Constant\ConfigKey;
return [
ConfigKey::MAIN => [
ConfigKey::OPTIONS => [
// Your Factorio username. This username is used to build a full download link, avoiding getting redirected
// to the login page.
// See https://wiki.factorio.com/Mod_portal_API#Downloading_Mods for further details.
ConfigKey::OPTION_USERNAME => 'your-username',
// The token to your username.
ConfigKey::OPTION_TOKEN => 'your-token',
// The timeout in seconds to use for the request. Defaults to 10 seconds.
ConfigKey::OPTION_TIMEOUT => 10,
],
],
];
/* @var \Psr\Container\ContainerInterface $container */
use BluePsyduck\FactorioModPortalClient\Client\Facade;
use BluePsyduck\FactorioModPortalClient\Request\ModRequest;
/* @var Facade $facade */
$facade = $container->get(Facade::class);
$mod = $facade->getMod((new ModRequest())->setName('FARL'));
// Do something with the received mod.
var_dump($mod->getDownloadsCount());
/* @var \Psr\Container\ContainerInterface $container */
use BluePsyduck\FactorioModPortalClient\Client\ClientInterface;
use BluePsyduck\FactorioModPortalClient\Request\ModRequest;
use BluePsyduck\FactorioModPortalClient\Response\ModResponse;
use function GuzzleHttp\Promise\all;
/* @var ClientInterface $client */
$client = $container->get(ClientInterface::class);
$request1 = (new ModRequest())->setName('FARL');
$request2 = (new ModRequest())->setName('FNEI');
/* @var ModResponse[] $responses*/
$responses = all([
'FARL' => $client->sendRequest($request1),
'FNEI' => $client->sendRequest($request2)
])->wait();
// Do something with the responses
var_dump($responses['FARL']->getSummary());
var_dump($responses['FNEI']->getSummary());