PHP code example of nellyt / free-to-game-api-wrapper

1. Go to this page and download the library: Download nellyt/free-to-game-api-wrapper 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/ */

    

nellyt / free-to-game-api-wrapper example snippets




$client = new \FreeToGame\Client();

$response = $client->fetchList();
$response = $client->fetchDetails($gameId);

$response->getResponse()->getStatusCode();

$response->getData();

$platformFilter = new \FreeToGame\Filters\PlatformFilter(new \FreeToGame\Filters\Platforms\Browser());

$filterCollection = new \FreeToGame\Filters\FilterCollection();
$filterCollection->setPlatformFilter($platformFilter);

$response = $client->fetchList($filterCollection);

$categoryFilter = new \FreeToGame\Filters\CategoryFilter(new \FreeToGame\Filters\SearchTerms\Shooter());

$filterCollection = new \FreeToGame\Filters\FilterCollection();
$filterCollection->setCategoryFilter($categoryFilter);

$response = $client->fetchList($filterCollection);

$searchTerms = [
    new \FreeToGame\Filters\SearchTerms\Shooter(),
    new \FreeToGame\Filters\SearchTerms\Strategy(),
    new \FreeToGame\Filters\SearchTerms\Racing(),
];

$tagFilter = new \FreeToGame\Filters\TagFilter($searchTerms);
$filterCollection = new \FreeToGame\Filters\FilterCollection();
$filterCollection->setTagFilter($tagFilter);

$response = $client->fetchList($filterCollection);

$shooter = \FreeToGame\Helpers\SearchTermFactory::getSearchTerm('shooter');
$searchTerms = \FreeToGame\Helpers\SearchTermFactory::getSearchTerms(['shooter', 'zombie', 'permadeath']);

$sort = new \FreeToGame\Sort\AlphabeticalSort();

$response = $client->fetchList(null, $sort);

$platformFilter = new \FreeToGame\Filters\PlatformFilter(new \FreeToGame\Filters\Platforms\Browser());

$searchTerms = [
    new \FreeToGame\Filters\SearchTerms\Shooter(),
    new \FreeToGame\Filters\SearchTerms\Strategy(),
    new \FreeToGame\Filters\SearchTerms\Racing(),
];
$tagFilter = new \FreeToGame\Filters\TagFilter($searchTerms);

$filterCollection = new \FreeToGame\Filters\FilterCollection();
$filterCollection->setPlatformFilter($platformFilter);
$filterCollection->setTagFilter($tagFilter);

$sort = new \FreeToGame\Sort\AlphabeticalSort();

$response = $client->fetchList($filterCollection, $sort);