• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML Http get request in json

Hello everyone! ^^
I would very much like some help. I am trying to apply a rule to my game to participate in an online event. The event organizers asked to create a DRM (a kind of in-game verification for when the event date ends, a message appears). In the implementation file it is written like this:


Make an HTTP GET request: https://time.patchkit.net/
Parse the response as JSON
Fetch either the “timestamp” (Unix time) or “datetime” value (ISO 8601) as UTC time.
Check if the time is bigger or equal to 2021-05-10:03:00 UTC (Unix timestamp: 1620608400).
If it is, display a message that the Event is over. At this moment you may want to close the game.



The problem is that I can't get the GM to take the data from that site and turn it into a date to make the comparison. Every time I use an http_get it returns 0. I tried to do this with other sites and it works.
 

chamaeleon

Member
Some event
GML:
time_req = http_get("https://time.patchkit.net/");
HTTP Async event
GML:
if (async_load[? "id"] == time_req) {
    if (async_load[? "status"] == 0) {
        var result = json_parse(async_load[? "result"]);
        show_debug_message(result.timestamp);
        show_debug_message(result.datetime);
    }
}
Code:
1618674237
2021-04-17T15:43:57Z
 
Top