Difference between revisions of "HTTP (API)"

From ComputerCraft Wiki
Jump to: navigation, search
m
(Updated to API overview v2)
Line 1: Line 1:
 +
{{NeedsWork|"A summary is required." need to be replaced. ''[[User:AfterLifeLochie|AfterLifeLochie]] 02:13, 1 December 2012 (MSK)''}}
 +
 
:{|class="wikitable"
 
:{|class="wikitable"
 
| '''The HTTP API must be enabled in mod_ComputerCraft.cfg before being used. To enable it open .minecraft/config/mod_ComputerCraft.cfg and change enableAPI_http=0 to enableAPI_http=1.'''
 
| '''The HTTP API must be enabled in mod_ComputerCraft.cfg before being used. To enable it open .minecraft/config/mod_ComputerCraft.cfg and change enableAPI_http=0 to enableAPI_http=1.'''
 
|}
 
|}
 +
 
The HTTP API allows interfacing with websites and downloading from them.
 
The HTTP API allows interfacing with websites and downloading from them.
  
=Methods=
+
<table style="width: 100%; border: solid 1px black; margin: 2px; border-spacing: 0px;">
{| border="1" cellpadding="2" cellspacing="0"
+
<tr><td colspan="2" style="font-weight: bold; font-size: large; padding-bottom: .3em; border-bottom: solid #C9C9C9 1px; background: #D3FFC2; line-height:28px;">
!style="background:#EEE" width="200px"|Method name
+
[[File:Grid_disk.png|24px]]&nbsp;&nbsp;
!style="background:#EEE" width="*"|Description
+
HTTP (API)
|-
+
</td></tr>
| [[http.request]]( url, *postData )<br />
+
 
|
+
<tr><td style="width: 350px; background: #E0E0E0; padding: .4em; font-weight:bold;">Method Name</td><td style="background: #E0E0E0; padding: .4em; font-weight:bold;">Description</td></tr>
|-
+
 
| [[http.get]]( url )
+
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[http.request]]( url, *postData )</td>
|
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">A summary is required.</td></tr>
|-
+
 
| [[http.post]]( url, postData )<br />
+
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[http.get]]( url )</td>
|
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">A summary is required.</td></tr>
|-
+
 
| * = Optional
+
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[http.post]]( url, postData )</td>
|
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">A summary is required.</td></tr>
|}
+
</table>
  
 
A period of time after a http.request() call is made, a "http_success" or "http_failure" event will be raised to os.pullEvent(). Arguments are the URL and a file handle if successful. http.get() blocks until this event is fired.
 
A period of time after a http.request() call is made, a "http_success" or "http_failure" event will be raised to os.pullEvent(). Arguments are the URL and a file handle if successful. http.get() blocks until this event is fired.
  
 
[[Category:APIs]]
 
[[Category:APIs]]

Revision as of 22:13, 30 November 2012

This page needs some serious TLC, stat!
Please help us by cleaning it, fixing it up, or sparing it some love.
(Reason: "A summary is required." need to be replaced. AfterLifeLochie 02:13, 1 December 2012 (MSK))
The HTTP API must be enabled in mod_ComputerCraft.cfg before being used. To enable it open .minecraft/config/mod_ComputerCraft.cfg and change enableAPI_http=0 to enableAPI_http=1.

The HTTP API allows interfacing with websites and downloading from them.

Grid disk.png   HTTP (API)

Method NameDescription
http.request( url, *postData ) A summary is required.
http.get( url ) A summary is required.
http.post( url, postData ) A summary is required.

A period of time after a http.request() call is made, a "http_success" or "http_failure" event will be raised to os.pullEvent(). Arguments are the URL and a file handle if successful. http.get() blocks until this event is fired.