Difference between revisions of "Http.request"

From ComputerCraft Wiki
Jump to: navigation, search
m (Moved to CAT:LuaCoreFunctions)
(Updated API reference)
Line 3: Line 3:
 
|name=http.request
 
|name=http.request
 
|returns=event "http_success" on success.
 
|returns=event "http_success" on success.
|api=http
+
|api=HTTP
 
|addon=ComputerCraft
 
|addon=ComputerCraft
 
|desc=Sends a HTTP request to the website. Returns event "http_success" on success.
 
|desc=Sends a HTTP request to the website. Returns event "http_success" on success.

Revision as of 13:57, 30 November 2012


Grid Redstone.png  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

Grid paper.png  Example
Prints the code of a loading bar program if successful.
Code
http.request("http://pastebin.com/raw.php?i=Tk19jv43")
local requesting = true
while requesting do
local event, url, sourceText = os.pullEvent()
if event == "http_success" then
local respondedText = sourceText.readAll()
print(respondedText)
requesting = false
elseif event == "http_failure" then
print("Server didn't respond.")
requesting = false
end end