PHP code example of mrt1m / playstation-store-api

1. Go to this page and download the library: Download mrt1m/playstation-store-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/ */

    

mrt1m / playstation-store-api example snippets



declare(strict_types=1);

use PlaystationStoreApi\Client;
use GuzzleHttp\Client as HTTPClient;
use PlaystationStoreApi\Enum\CategoryEnum;
use PlaystationStoreApi\Enum\RegionEnum;


use PlaystationStoreApi\Request\RequestProductById;

/**
 * Example for https://store.playstation.com/en-us/product/UP0001-CUSA09311_00-GAME000000000000
 */
$response = $client->get(new RequestProductById('UP0001-CUSA09311_00-GAME000000000000'));

use PlaystationStoreApi\Request\RequestConceptById;

/**
 Example for https://store.playstation.com/en-us/concept/10002694
 */
$response = $client->get(new RequestConceptById('10002694'));

use PlaystationStoreApi\Request\RequestProductList;

$request = RequestProductList::createFromCategory(CategoryEnum::PS5_GAMES);

$firstPageResponse = $client->get($request);

$nextPageResponse = $client->get($request->createNextPageRequest());

use PlaystationStoreApi\RequestLocatorService;
use PlaystationStoreApi\Request\RequestPSPlusTier;

$customRequestLocatorService = RequestLocatorService::default();
$customRequestLocatorService->set(RequestPSPlusTier::class, 'new sha256Hash value')

declare(strict_types=1);

use PlaystationStoreApi\Client;
use GuzzleHttp\Client as HTTPClient;
use PlaystationStoreApi\Enum\CategoryEnum;
use PlaystationStoreApi\Enum\RegionEnum;

const API_URL = 'https://web.np.playstation.com/api/graphql/v1/';

$client = new Client(
    RegionEnum::UNITED_STATES, 
    new HTTPClient(['base_uri' => API_URL, 'timeout' => 5]), 
    $customRequestLocatorService
);