Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to use httpservice?

Asked by 9 years ago
hs = game:GetService("HttpService")
test = hs:GetAsync("http://www.roproxy.tk/Asset/AvatarAccoutrements.ashx?userId=57686851", true)
print(test)

This one printed the body of the html

hs = game:GetService("HttpService")=
test = hs:GetAsync("http://www.roproxy.tk/Asset/AvatarAccoutrements.ashx?userId=57686851", true)
local Items = hs:JSONDecode(test)

when i tried to decode the JSON this error came out Can't parse JSON

now i want to use the data i obtained to turn it into a character changing appearance without dying is there a way to turn the data to a table?

0
I can't help much more then this, look up more information about it on Roblox Wiki: http://wiki.roblox.com/index.php?title=HttpService_for_Dummies alphawolvess 1784 — 9y

1 answer

Log in to vote
0
Answered by
Abaw7 5
9 years ago

There is a CharacterAppearance Property of Players might be more useful for this.

Now, to answer your question: Because it's in JSON, you first have to decode it into a Table, this can be done Via:

local URLs = {}
hs = game:GetService("HttpService")
test = hs:GetAsync("http://www.roproxy.tk/Asset/AvatarAccoutrements.ashx?userId=57686851", true)
for String in string.gmatch(test, "(.-);") do 
URLs[#URLS + 1] = String;
end
0
Can't parse JSON SomeoneYetUnnoticed 31 — 9y
0
Oh, look at that, it's not returnning JSON, let me modify the code above Abaw7 5 — 9y
0
There, changed to fix it, basically, it's using gmatch from the string library to catch the URLs which are conveniently separated by semicolons Abaw7 5 — 9y
0
Do note the last one doesn't end with a semi-colon, so something more like "([^;]+)" (anything not a semicolon+) would work better. Edited your answer move the link from plaintext to an actual link with text. User#2 0 — 9y
Ad

Answer this question