Tom wrote:
> Isn't this the way to handle the GET method? I know how to do that,
> but I'd suppose the POST method should be handled otherwise.
Here's a couple of code fragments from my %pcspager.r script, which
collects e-mail from a POP3 mailbox and sends it via HTTP POST to my
PCS cellular phone.
Hopefully the code is self-explanatory, the fragments below are the
important part for preparing and submitting the POST to the server
specified in variables pagerserver and pagerscript. The actual
posting format used is specific to Cantel/AT&Ts PCS messaging form.
Hope this helps....
Kev
[included text from %pcspager.r]
pagerserver: tcp://sabre.cantelatt.com:80
pagerscript: "/cgi-bin/sendpcs.cgi"
eol: "^M^J"
comment { The url-encode function was appropriated from the REBOL website at
www.rebol.com/library/urlencode.r The original author was uncredited.
The original code needed one change, the ^ needed to be escaped with another ^
}
url-encode: function [string] [punctuation encoding result f][
punctuation: { !@#$%&()+=[]\{}|;':",/<>?`~^^}
encoding: ["%20" "%21" "%40" "%23" "%24" "%25"
"%26" "%28" "%29" "%2B" "%3D" "%5B"
"%5D" "%5C" "%7B" "%7D" "%7C" "%3B"
"%27" "%3A" "%22" "%2C" "%2F" "%3C"
"%3E" "%3F" "%60" "%7E" "%5E"
]
result: copy ""
foreach character string [
insert tail result either f: find punctuation character
[pick encoding index? f]
[character]
]
return result
]
encodemessage: url-encode textmsg
encodesender: url-encode make string! sender
submit: join "" ["AREA_CODE=" targetarea "&PIN1=" targetprefix "&PIN2=" targetnumber
"&emapnew--DESC--which=ORIG" "&SENDER=" encodesender
"&PAGETEXT1=" encodemessage
"&SIZEBOX=" truelength "&SIZEBOXW=" wordcount
"&SUBMIT=Send+Message"]
post: join "POST "[ pagerscript " HTTP/1.0" eol
"Content-Type: application/x-www-form-urlencoded" eol
"Referer: http://www.cantelatt.com/voice/amigo/message.html" eol
"Content-Length: " length? submit eol
eol
submit eol
]
comment {Submit the message to Cantel's server}
pcspage: open/binary pagerserver
insert pcspage post
comment {If you want to retrieve the confirmation page, you need this bit from the
REBOL
mailing list. Thanks Gabriele!}
buffer: make string! 4096
result: make string! 4096
while [(read-io pcspage buffer 4096) <> 0] [
append result buffer
clear buffer
wait pcspage
]
close pcspage
[end included text]
------------------------------------------------------------------------
Kevin McKinnon, Network Engineer [EMAIL PROTECTED]
Sunshine Communications http://www.sunshinecable.com
**NOTE NEW E-MAIL ADDRESS**
PGP Public Key: http://www.dockmaster.net/pgp.html PGP 6.0 www.pgp.com