varandas/epic-free-games

这是一个小巧的PHP包,旨在简化与Epic Games Store API的交互,使开发者能够检索当前可用的免费游戏详情。

v1.0.1 2023-10-30 10:39 UTC

This package is auto-updated.

Last update: 2024-09-30 01:52:26 UTC


README

概述

这是一个简单的包,从Epic Games Store获取当前免费游戏并返回。

安装

composer require varandas/epic-free-games

使用方法

<?php

use Varandas\EpicFreeGames\EpicFreeGames\EpicGamesService;

// Create an instance
$epicGamesService = new EpicGamesService();

// Get free games
$games = $epicGamesService->getFreeGames();

// Process the retrieved games
// ...

设置国家和区域

<?php

use Varandas\EpicFreeGames\EpicFreeGames\EpicGamesService;

// Create an instance
$epicGamesService = new EpicGamesService();

// Set country and locale
$epicGamesService->setCountry('BR')->setLocale('pt-BR');

// Get free games
$games = $epicGamesService->getFreeGames();

// Process the retrieved games
// ...

游戏对象

游戏对象 Varandas\EpicFreeGames\Models\EpicGame 拥有以下获取器

这是如何使用获取器的示例

<?php

use Varandas\EpicFreeGames\EpicFreeGames\EpicGamesService;

// Create an instance
$epicGamesService = new EpicGamesService();

// Get free games
$games = $epicGamesService->getFreeGames();

// Process the retrieved games
foreach ($games as $game) {
    $title = $game->getTitle();
    $id = $game->getId();
    $namespace = $game->getNamespace();
    $description = $game->getDescription();
    $effectiveDate = $game->getEffectiveDate();
    $offerType = $game->getOfferType();
    $expiryDate = $game->getExpiryDate();
    $viewableDate = $game->getViewableDate();
    $isCodeRedemptionOnly = $game->isCodeRedemptionOnly();
    $status = $game->getStatus();
    $keyImages = $game->getKeyImages();
    $seller = $game->getSeller();
    $productSlug = $game->getProductSlug();
    $urlSlug = $game->getUrlSlug();
    $url = $game->getUrl();
    $items = $game->getItems();
    $customAttributes = $game->getCustomAttributes();
    $categories = $game->getCategories();
    $tags = $game->getTags();
    $catalogNs = $game->getCatalogNs();
    $offerMappings = $game->getOfferMappings();
    $price = $game->getPrice();
    $promotions = $game->getPromotions();
    $promotionalOffers = $game->getPromotionalOffers();
    $upcomingPromotionalOffers = $game->getUpcomingPromotionalOffers();
    
    // Do something with the data
    // ...
}

样本响应

这是Epic Games Store API响应的示例 - 以便您了解可用数据。

{
    "title":"Tandem: A Tale of Shadows",
    "id":"9142916d80f54720b01f8f62b21014be",
    "namespace":"d1a3ff292b2f4ee289a83d7a91ae3458",
    "description":"Tandem : A Tale of Shadows redefines the puzzle platformer genre with a unique gameplay and exceptional aesthetics. Help Emma and the teddy bear Fenton solve the mystery of the disappearance of the famous magician Thomas Kane.",
    "effectiveDate":"2021-10-21T16:00:00.000Z",
    "offerType":"BASE_GAME",
    "expiryDate":null,
    "viewableDate":"2021-07-16T16:00:00.000Z",
    "status":"ACTIVE",
    "isCodeRedemptionOnly":false,
    "keyImages":[
        {
            "type":"OfferImageWide",
            "url":"https://cdn1.epicgames.com/spt/c087c527-0c2b-4269-926b-f0d15102de8a/tandem-a-tale-of-shadows-offer-633449e1.jpg"
        },
        {
            "type":"OfferImageTall",
            "url":"https://cdn1.epicgames.com/spt/2c1d81ab-12e7-40a6-9edd-a449cc619ad5/download-tandem-a-tale-of-shadows-offer-5c6a45df.jpg"
        },
        {
            "type":"Thumbnail",
            "url":"https://cdn1.epicgames.com/spt/2c1d81ab-12e7-40a6-9edd-a449cc619ad5/download-tandem-a-tale-of-shadows-offer-5c6a45df.jpg"
        }
    ],
    "seller":{
        "id":"o-722pvnj3qsvbzvskhx4r8x7gcxhhbn",
        "name":"Hatinh Interactive"
    },
    "productSlug":null,
    "urlSlug":"24ed2fb76b334158b9e580c01f7282a6",
    "url":null,
    "items":[
        {
            "id":"7c02053bfee24d028aa1bec03edd6a82",
            "namespace":"d1a3ff292b2f4ee289a83d7a91ae3458"
        }
    ],
    "customAttributes":[
        {
            "key":"autoGeneratedPrice",
            "value":"false"
        },
        {
            "key":"isBlockchainUsed",
            "value":"false"
        }
    ],
    "categories":[
        {
            "path":"freegames"
        },
        {
            "path":"games"
        },
        {
            "path":"games/edition"
        },
        {
            "path":"games/edition/base"
        }
    ],
    "tags":[
        {
            "id":"1298"
        },
        {
            "id":"18051"
        }
    ],
    "catalogNs":{
        "mappings":[
            {
                "pageSlug":"tandem-a-tale-of-shadows-c3f55e",
                "pageType":"productHome"
            }
        ]
    },
    "offerMappings":[
        {
            "pageSlug":"tandem-a-tale-of-shadows-c3f55e",
            "pageType":"productHome"
        }
    ],
    "price":{
        "totalPrice":{

        },
        "lineOffers":[

        ]
    },
    "promotions":{
        "promotionalOffers":[
            {
                "promotionalOffers":[
                    {
                        "startDate":"2023-10-18T15:00:00.000Z",
                        "endDate":"2023-11-01T15:00:00.000Z",
                        "discountSetting":{
                            "discountType":"PERCENTAGE",
                            "discountPercentage":50
                        }
                    },
                    {
                        "startDate":"2023-10-26T15:00:00.000Z",
                        "endDate":"2023-11-02T15:00:00.000Z",
                        "discountSetting":{
                            "discountType":"PERCENTAGE",
                            "discountPercentage":0
                        }
                    }
                ]
            }
        ],
        "upcomingPromotionalOffers":[
            {
                "promotionalOffers":[
                    {
                        "startDate":"2023-12-16T23:00:00.000Z",
                        "endDate":"2023-12-31T11:00:00.000Z",
                        "discountSetting":{
                            "discountType":"PERCENTAGE",
                            "discountPercentage":40
                        }
                    }
                ]
            }
        ]
    }
}

免责声明

所使用材料的部分是Epic Games, Inc.的商标和/或版权作品。Epic保留所有权利。此材料非官方,未经Epic认可。

许可证

此包采用MIT许可证 - 请参阅LICENSE文件以获取详细信息。