Hello!
So I heard about API and im REALLY interested in it. So I started using the API services today…
The first task which is to find out how many friends you got in your roblox profile!
using this document (Roblox offical document)
after reading its information. I attempt to write this code:
wait()
local url = "https://friends.roblox.com/v1/my/friends/count"
local httpservice = game:GetService("HttpService")
local response = httpservice:GetAsync(url)
local data = httpservice:JSONDecode(response)
if data.message == "success" then
print(data.count)
end
The problem is when i finished it. It throws me an error:
Since this is my first to encounter the API. I have no idea how to fix it
I read the API carefully and other devforum topics. But nothing seems to work
My guess as to why the previous link doesn’t work might be because it requires something browsers typically have, which Studio doesn’t (maybe login cookies)?
wait(7)
print("Loaded!")
local url = "friends.roproxy.com/v1/users/2036013757/friends/count"
local httpservice = game:GetService("HttpService")
local response = httpservice:GetAsync(url)
local data = httpservice:JSONDecode(response)
if data.message == "success" then
local count = data.count
game.Workspace:WaitForChild("Part").SurfaceGui.TextLabel.Text = tostring(count)
else
print("Not sucess..")
end
wait(7)
print("Loaded!")
local id = '2036013757'
local url = "friends.roproxy.com/v1/user/1/followers/count"
local httpservice = game:GetService("HttpService")
local response = httpservice:GetAsync(url)
local data = httpservice:JSONDecode(response)
if data.message == "success" then
local count = data.count
game.Workspace:WaitForChild("Part").SurfaceGui.TextLabel.Text = tostring(count)
else
print("Not sucess..")
end