Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Newbie: Trouble filling a form using "http-post.r"

From: cybarite:sympatico:ca at: 9-Jun-2002 8:02

Matthew, I don't know if you got Scott's approach working or not. He is using the more native approach rather than what is in %http-port.r For the rogers message, this html seems to allow a post with <all | most> of the extraneous html (and javascript) removed <html><head><title>Mr Rogers</title></head> <body bgcolor=linen> <form ACTION="http://216.129.53.44:8080/cgi-bin/send_sm_rogers.new" method=POST> <INPUT TYPE="submit" VALUE="send message"> <INPUT type="hidden" name="msisdn" value="4165551212"> <input type="hidden" name="num1" value="416"> <input type="hidden" name="num2" value="5551212"> <input type="hidden" name="text" value="This is a test"> <input type="hidden" name=sizebox value="14"> <input type="hidden" name="sm_title" value="Rogers | Wireless"> <input type="hidden" name="sm_header_ok" value="Thank You"> <input type="hidden" name="sm_header_fail" value="Sorry"> <input type="hidden" name="sm_ym" value="Your Message: "> <input type="hidden" name="sm_status_ok" value="has been sent to:"> <input type="hidden" name="sm_status_fail" value="cannot presently be sent to: "> <input type="hidden" name="sm_logo" value="/att-logo.gif"> <input type="hidden" name="sm_pcs_link" value="http://www.rogers.com/english/wireless/sendpcs.html"> <input type="hidden" name="sm_pcs_text" value="Send a PCS message"> <input type="hidden" name="sm_home_link" value="http://www.rogers.com"> <input type="hidden" name="sm_home_text" value="home"> </form> </body></html> I did not look at their approach too long but I think they are passing some parameters to the cgi message that are then echoed back on the response. So the original posting message already knows the logo, and possible error or success messages. For example, you can change the success message to "has, we think, really been sent to:" I think this is clever ... allowing you to control some output on the response page and make your parsing work easier. And making you a bit more independent of changes to the processing program. If you want to use the functions in http-post.r then you can add a new one that allows a message to be sent For example, this send-message function works for me using the values show and it uses the http-post-form function from http-post.r send-message: func [ {Sends a message} area-code phone-number message ][ not-lt-gt: complement charset [#"<" #">"] tag-rule: ["<" some not-lt-gt ">"] tmp: http-post-form http://216.129.53.44:8080/cgi-bin/send_sm_rogers.new? reduce [ "msisdn" join area-code phone-number "num1" area-code "num2" phone-number "oldtext" "" "text" message "SIZEBOX" to-string length? message "submit" "send message" "sm_ym" "Your Message: " "sm_status_ok" "has been sent to:" "sm_status_fail" "cannot presently be sent to: " "sm_logo" "/att-logo.gif" "sm_home_link" "http://www.rogers.com" "sm_home_text" "home" ] if none? find tmp/HTTP-Response "200" [return join "Error: " tmp/HTTP-Response] either parse tmp/content [ ; very ugly parsing attempt thru "Your Message: <br>" to {</b><br>} thru "<br>" copy trans to {</font>} to end ; changed parse value ][ return trans ][ print ["Content was: " tmp/content] return "Error: Unable to parse HTML result page" ] ] print send-message "416" "5551212" "This is a test" but note the comment about the parsing... very ugly and very specific (and limited) to this example.