Towren
(Tow)
June 3, 2021, 8:23pm
#1
This is my first time using APIs and I’m very confused. I’m trying to get a user’s online status and print it in the output. Here is my code:
local httpService = game:GetService("HttpService")
local data = httpService:GetAsync("http://https://api.roblox.com/users/38152945/onlinestatus/")
data = httpService:JSONDecode(data)
print(data)
I’m most likely doing something wrong. All help appreciated!
LMVM2041
(League)
June 3, 2021, 8:23pm
#2
Do you have HTTPS requests turned on?
1 Like
Towren
(Tow)
June 3, 2021, 8:24pm
#3
Yes. Did it in game settings. Definitely turned on.
Towren
(Tow)
June 3, 2021, 8:25pm
#4
Gives me this error:
HttpError: InvalidUrl
SOTR654
(SOTR654)
June 3, 2021, 8:38pm
#5
You are missing the proxy and it was misspelled:
local data = httpService:GetAsync("https://api.rprxy.xyz/users/38152945/onlinestatus/")
1 Like
adamaniac
(adamaniac)
June 3, 2021, 8:38pm
#6
local data = httpService:GetAsync("http://https://api.roblox.com/users/38152945/onlinestatus/")
Should be:
local data = httpService:GetAsync("https://api.roblox.com/users/38152945/onlinestatus/")
1 Like
Towren
(Tow)
June 3, 2021, 8:40pm
#7
That gives me an error of InvalidUrl
Towren
(Tow)
June 3, 2021, 8:40pm
#8
That gives me an error of trust check failed
SOTR654
(SOTR654)
June 3, 2021, 8:41pm
#9
Check again, @adamaniac has part of the solution.
uugnut6
(uugnut6)
June 3, 2021, 9:02pm
#10
JSONDecode returns a table you cant print tables
You can’t send requests directly to Roblox from a game, you will need to use a proxy to make the request for you.
uugnut6
(uugnut6)
June 3, 2021, 9:35pm
#12
this works, just have to look at this Tables | Roblox Creator Documentation
SOTR654
(SOTR654)
June 3, 2021, 9:42pm
#13
Amm, I know, I just corrected what I provide @Towren , maybe he know it too and cut that part.
In addition, the tables can be printed: