Difference between revisions of "Http.request"
From ComputerCraft Wiki
(oops, wrong page) |
(Add function layout + information) |
||
Line 1: | Line 1: | ||
− | + | {{lowercase}} | |
+ | {{Function | ||
+ | |name=http.request | ||
+ | |returns=event "http_success" on success. | ||
+ | |api=http | ||
+ | |addon=ComputerCraft | ||
+ | |desc=Sends a HTTP request to the website. Returns event "http_success" on success. | ||
+ | |examples= | ||
+ | {{Example | ||
+ | |desc=Prints the code of a loading bar program if successful. | ||
+ | |code=http.request("http://pastebin.com/raw.php?i=Tk19jv43")<br /> | ||
+ | requesting = true<br /> | ||
+ | while requesting do<br /> | ||
+ | local event, url, sourceText = os.pullEvent()<br /> | ||
+ | if event == "http_success" then<br /> | ||
+ | respondedText = code.readAll()<br /> | ||
+ | print(respondedText)<br /> | ||
+ | requesting = false<br /> | ||
+ | else<br /> | ||
+ | print("Server didn't respond.")<br /> | ||
+ | requesting = false<br /> | ||
+ | end | ||
+ | end | ||
+ | }} | ||
+ | }} |
Revision as of 03:06, 3 July 2012
Function http.request | |
Sends a HTTP request to the website. Returns event "http_success" on success. | |
Syntax | http.request() |
Returns | event "http_success" on success. |
Part of | ComputerCraft |
API | http |
Examples
Example | |
Prints the code of a loading bar program if successful. | |
Code |
http.request("http://pastebin.com/raw.php?i=Tk19jv43") |