syntaxerrors / Steam

A composer package to make use of the steam web api.
https://packagist.org/packages/syntax/steam-api
MIT License
160 stars 55 forks source link

How can I call the game icon? #131

Open mrranger opened 2 years ago

mrranger commented 2 years ago

I'm trying to call the game icon, but instead of the picture I always get a link to the steam picture I want to make sure that each game has its own picture help me please Require

Laravel 9 + AdminLTE

https://prnt.sc/N_Kh8b6l9HV6

                   @if(isset($account->OwnedGames) && count($account->OwnedGames) > 0)
                        <div class="row col justify-content-center">
                            <label for="GameList" class="text-center">Game List</label>
                        </div>

                        <div class="row col justify-content-center">
                            <select name="GameList" id="multiSelect" multiple="multiple">

                                @foreach($account->OwnedGames as $game)
                                    <option  value="{{$game->appId}}">{{$game->name}} </option>

                                @endforeach

                             </select>
                         </div>
                     @else
Teakowa commented 1 year ago

Let me think about it, You are trying to get the game icon like Dota is right?

If so, game icons are provided by two APIs under IPlayerService:

https://api.steampowered.com/IPlayerService/GetOwnedGames/v1/
https://api.steampowered.com/IPlayerService/GetRecentlyPlayedGames/v1/

The API will return a img_icon_url key, it looks like this: 0bbb630d63262dd66d2fdd0f7d37e8661a410075

Then you can get the icon by url splicing:

https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/apps/{appid}/{img_icon_url}.jpg
https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/apps/570/0bbb630d63262dd66d2fdd0f7d37e8661a410075.jpg

But I remember that this package provides this feature, i see in

https://github.com/syntaxerrors/Steam/blob/09974abbadf89f928ff7a9cde78a4ff1e5844fe4/src/Syntax/SteamApi/Containers/Game.php#L35-L36

https://github.com/syntaxerrors/Steam/blob/09974abbadf89f928ff7a9cde78a4ff1e5844fe4/src/Syntax/SteamApi/Steam/Player.php#L74-L99

You can use

Steam::player($steamId)->GetOwnedGames();
Steam::player($steamId)->GetRecentlyPlayedGames()

to get game icon.

For more information you can refer to package documentation or Steam Web API Documentation by xPaw.