diff --git a/gamejolt.lua b/gamejolt.lua index bcf5611..fce0327 100644 --- a/gamejolt.lua +++ b/gamejolt.lua @@ -1,5 +1,5 @@ local md5 = require "md5" -local http = require "http" +local http = require "socket.http" local GJ = { gameID, gameKey, @@ -7,10 +7,10 @@ local GJ = { username, userToken } -local BASE_URL = "http://gamejolt.com/api/game/v1" +local BASE_URL = "http://gamejolt.com/api/game/v1/" -local function req(s, pu, pt, f) - local url = s .. "&game_id=" .. tostring(GJ.gameID) .. "&format=" .. f +local function req(s, f, pu, pt) + local url = BASE_URL .. s .. "&game_id=" .. tostring(GJ.gameID) .. "&format=" .. f if pu then url = url .. "&username=" .. GJ.username end if pt then url = url .. "&user_token=" .. GJ.userToken end @@ -26,4 +26,14 @@ function GJ.init(id, key) GJ.gameKey = key end +-- users +function GJ.authUser(name, token) + GJ.username = name + GJ.userToken = token + + local s = string.find(req("users/auth/?", "dump", true, true), "SUCCESS") ~= nil + GJ.isLoggedIn = s + return s +end + return GJ \ No newline at end of file