Unable to filter games by date_added!

Avatar image for thefierytaco
TheFieryTaco

3

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

#1  Edited By TheFieryTaco

Hi!

I'd like to query once every day for a list of PC games that have been just added (in the past 24 hours) and write some info about each to a .json file.

My problem is, I'm not quite sure how to format the query. The following attempt in PHP returns the entire list of PC games (~20000) sorted by date_added. I'd like ONLY games added in the past 24 hours, sorted as descending:

$date = urlencode(date('Y-m-d H:i:s'));

$lastCheck = urlencode(date("Y-m-d H:i:s", strtotime("-24 hours")));

$gamesQuery = file_get_contents('http://www.giantbomb.com/api/games/?api_key=[myKey]&format=json&platforms=94&sort=date_added:desc&filter=date_added:'.$lastCheck.'|'.$date);

How must I format &filter=date_added to achieve what I want?

Any advice is appreciated, thank you! :)

Avatar image for hogonalog
hogonalog

20

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

#2  Edited By hogonalog

@thefierytaco: I think your code is right. The date format and URL are both correct.

However, it looks like there's an API issue when using both a filter and a platforms field. If you try using a second filter instead of the platforms field, it should do what you want:

http://api.giantbomb.com/games?limit=10&offset=0&filter=date_added:2016-04-14 00:00:00|2016-04-15 19:19:14,platforms:94&api_key=[API_KEY]&format=json

Avatar image for thefierytaco
TheFieryTaco

3

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

@thefierytaco: I think your code is right. The date format and URL are both correct.

However, it looks like there's an API issue when using both a filter and a platforms field. If you try using a second filter instead of the platforms field, it should do what you want:

http://api.giantbomb.com/games?limit=10&offset=0&filter=date_added:2016-04-14 00:00:00|2016-04-15 19:19:14,platforms:94&api_key=[API_KEY]&format=json

I'll try that later tonight and report back.

Thanks a ton.