PHP code example of refatbd / game-account-lookup

1. Go to this page and download the library: Download refatbd/game-account-lookup 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/ */

    

refatbd / game-account-lookup example snippets




efatbd\GameAccountLookup\Cache\ArrayCache;
use Refatbd\GameAccountLookup\GameAccountLookup;

$lookup = GameAccountLookup::make([
    'cache' => new ArrayCache(),
    'cache_ttl' => 300,
    'session_ttl' => 1800,
]);

$result = $lookup->check('freefire', '4422076728');

echo json_encode(
    $result,
    JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE
);

$result = $lookup->check('mobilelegends', 'USER_ID', 'ZONE_ID');
$result = $lookup->check('genshin', 'UID', 'os_asia');

$result = $lookup->check(
    'freefire',
    '4422076728',
    bypassCache: true,
);

$result = $lookup->check(
    'freefire',
    '4422076728',
    providerOrder: ['codashop_dynamic'],
    bypassCache: true,
);

use Refatbd\GameAccountLookup\GameAccountLookup;

public function check(GameAccountLookup $lookup)
{
    return response()->json(
        $lookup->check('pubgm', request('player_id'))
    );
}

use Refatbd\GameAccountLookup\Laravel\Facades\GameAccountLookup;

$result = GameAccountLookup::check('mlbb', 'USER_ID', 'ZONE_ID');

Route::get('/game-account', PlayerLookupController::class)
    ->middleware('throttle:30,1');

$games = $lookup->registry()->list();
$matches = $lookup->registry()->search('pubg');

$result = $lookup->check(
    'freefire',
    '4422076728',
    providerOrder: ['codashop_dynamic', 'gopaygames', 'codashop'],
);

$freeFire = $lookup->check(
    'freefire',
    'PLAYER_ID',
    providerOrder: ['garena', 'gopaygames', 'codashop', 'codashop_dynamic'],
);

$pubg = $lookup->check(
    'pubgmobile',
    'PLAYER_ID',
    providerOrder: ['midasbuy', 'gopaygames'],
);

use Refatbd\GameAccountLookup\Contracts\ProviderInterface;
use Refatbd\GameAccountLookup\DTO\LookupResult;

final class OfficialGameProvider implements ProviderInterface
{
    public function key(): string
    {
        return 'official_game';
    }

    public function supports(array $game): bool
    {
        return isset($game['providers'][$this->key()]);
    }

    public function lookup(
        array $game,
        string $playerId,
        ?string $zoneId = null
    ): LookupResult {
        // Call an authorized API here.

        return LookupResult::success(
            $game['code'],
            $playerId,
            'PlayerName',
            $this->key(),
            $zoneId,
        );
    }
}

$lookup
    ->registerProvider(new OfficialGameProvider())
    ->registerGame('official-game', [
        'label' => 'Official Game',
        'aliases' => ['og'],
        '

'examplegame' => [
    'code' => 'examplegame',
    'label' => 'Example Game',
    'aliases' => ['eg'],
    '',
        ],
        'codashop' => [
            'vppId' => 12345,
            'price' => '10000.0000',
            'voucherTypeName' => 'EXAMPLE_GAME',
            'zone' => 'user',
            'nicknamePaths' => [
                'confirmationFields.username',
            ],
        ],
    ],
];
bash
php artisan vendor:publish --tag=game-account-lookup-config
bash
php tools/audit-provider-catalog.php
php tools/audit-provider-catalog.php --live
composer docs:games
composer quality