B
B
BonBon Slick2017-01-02 13:39:04
PHP
BonBon Slick, 2017-01-02 13:39:04

How to pull the entire list of Steam games?

There is a URL where all the games are written as a json string. How
now to pull them out from there to your site?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
BonBon Slick, 2017-01-02
@BonBonSlick

An hour later, I decided myself here is the answer:
PHP function where we refer.

$allGamesObject = json_decode(file_get_contents(asset('/json/games.txt')));
// тут можно использовать URL, файл или БД для выборки. 
return $allGames = $allGamesObject->applist->apps->app;
// вернет массив обьектов. Каждая игра обьект.

And js for output on the front.
var token = $('input[name="_token"]').val(),
 gameName = $('#gameName').val();

            $.ajax({
                url: '/getsteamgames',
                type: 'POST',
                dataType: 'json',
                data: {
                    'gameName': gameName,
                    '_token': token,
                },
            })
            .done(function(data) {
                $.each(data, function(index, element) {
                    var  game_name = element.name;
                    $('body').prepend( game_name );
                });
            })
            .fail(function() {
                console.log("ERROR");
            });

D
dev400, 2017-01-02
@dev400

public function getGamesArray($url) {

        $json = file_get_contents($url);

        return json_decode(str_replace("'", '"', $json), true);

    }

ZY: Your link is an empty array

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question