Uh oh!
There was an error while loading. Please reload this page.
Aurora Lua Http Library #44
JoshWaldram2003
started this conversation in
General
Replies: 1 comment
Aurora Http Lua LibraryDocumentation
The table returned by Http.Get is of the form:
The table returned by Http.Post is of the form:
Example ScriptscriptTitle="HTTP Test"scriptAuthor="jrobiche"scriptVersion=1scriptDescription="HTTP Test"scriptPermissions= { "filesystem", "http" }
functionmain()
locallistContent= {}
listContent[1] ="Execute Http.Get()"listContent[2] ="Execute Http.Post()"localret=Script.ShowPopupList(
"Execute Http Function",
"No options available",
listContent
)
ifret.Selected.Key==1thenhttpGetExample()
elseifret.Selected.Key==2thenhttpPostExample()
endendfunctionhttpGetExample()
localresponse=Http.Get("http://jsonplaceholder.typicode.com/posts/1", "get_response.json")
tprint(response)
-- Display response detailslocalmsg="ResponseCode: " ..response["ResponseCode"] .."\n";
msg=msg.."Url: " ..response["Url"] .."\n";
msg=msg.."Success: " ..tostring(response["Success"]) .."\n";
msg=msg.."Canceled: " ..tostring(response["Canceled"]) .."\n";
msg=msg.."OutputPath: " ..response["OutputPath"] .."\n";
Script.ShowMessageBox("Response Details", msg, "OK");
-- Display response contentlocalresponseContent=FileSystem.ReadFile("Game:\\User\\Scripts\\Utility\\HttpTest\\get_response.json")
print(responseContent)
Script.ShowMessageBox("Response Content", responseContent, "OK");
endfunctionhttpPostExample()
localvars= {}
vars["title"] ="foo"vars["body"] ="bar"vars["userId"] =1localresponse=Http.Post("http://jsonplaceholder.typicode.com/posts", vars, "post_response.json")
tprint(response)
-- Display response detailslocalmsg="ResponseCode: " ..response["ResponseCode"] .."\n";
msg=msg.."Url: " ..response["Url"] .."\n";
msg=msg.."Success: " ..tostring(response["Success"]) .."\n";
msg=msg.."Canceled: " ..tostring(response["Canceled"]) .."\n";
Script.ShowMessageBox("Response Details", msg, "OK");
-- Display response contentlocalresponseContent=FileSystem.ReadFile("Game:\\User\\Scripts\\Utility\\HttpTest\\post_response.json")
print(responseContent)
Script.ShowMessageBox("Response Content", responseContent, "OK");
end |
0 replies
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
What library is used for Http?
I'm trying to debug a script i'm creating but i cant seem to find out if im recieving any error codes.
Using http.Success just kicks me back to the scripts main menu.
I would like to know what library is used or if there is any docs online for it.
Thanks
All reactions