Re: how to communicate with a server?

new topic     » goto parent     » topic index » view thread      » older message » newer message
include std/net/http.e -- Eu4.0 
enum HEADER, BODY 
object data 
data = get_url("http://foo.com/cgi/somecgi","userid=joe&password=guessme") 
puts(1,data[HEADER]) 
-- do something with data[BODY], like parse out the info you need... 

Now, if you're accessing a web page (yours or someone else's) with a browser to enter the numbers & press the button, you are going to get the results back as a web page in the browser - which Euphoria won't see.

So probably you'll want to determine from looking at the first web page source what the names of the fields are, and use those in your get_url() request instead of entering them on the original web page. Confused?

Here's a simple web form: http://isthe.com/cgi-bin/cgi-example.cgi Look at it first with a browser, then view the source. You'll see the names of the form fields, like <input type="text" name="yourname" value="Your name here" /> Use those field names to send data directly from your Euphoria program.

if you request that page using the above short program with the line:

data = get_url("http://isthe.com/cgi-bin/cgi-example.cgi","yourname=FooBaz&color=blue") 

The returned web page will have html using those values:

Your name is:  
<b>FooBaz</b> 
<p /> 
The keywords are:  
<em></em> 
<p /> 
Your favorite color is:  
<tt>blue</tt> 

Obviously, you'll have to parse out the parts you need to use.

If you're writing the cgi yourself, it's much easier - you don't need to return a web page full of html at all, just send plain text back.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu