Home   Archive   Permalink



Can REBOL send to web site, like...

http://the contest.com/u/soupysales?vote_from=Dr+Frankenstein
    
Can you submit this directly to a Site, or change what's in the browser bar?


posted by:   Gs       7-Aug-2013/13:05:07-7:00



Sure you can do that:
    
     print read http://google.com/search?q=test
or
     write %test.html read http://google.com/search?q=test
    
you can also POST to a form using /CUSTOM refinement
url: http://example.com/cgi-bin/form.cgi
data: read/binary %localfile.exe
result: read/custom url reduce ['post data]
    
See the links below for further info:
http://www.rebol.net/cookbook/
http://www.rebol.net/cookbook/recipes/0059.html
http://www.rebol.net/cookbook/recipes/0026.html
http://stackoverflow.com/questions/8691754/how-to-send-an-http-post-with-a-custom-header-using-rebol
http://www.codeconscious.com/rebol/rebol-net.html#HTTP


posted by:   Endo       8-Aug-2013/10:40:16-7:00



So, this would submit a Vote?
    
{Assuming that they had the oversight to count a vote whhen the name in the browser bar is changed, and Enter is pressed}
    
print read http://voting.contest.com/u/Soupy_Sales?vote=Gayle+Winters
    
How could you tell from a server response?
Or 'could' you?
    
    
    


posted by:   Gus       8-Aug-2013/15:34:40-7:00



Yes, if server accepts HTTP GET request (parameters from the URL) then it would work.
    
if it accepts only POST data then you need to use the other solutions. (read/custom)
    
READ function returns the server response (an HTML web site, most probably)
    
Then you can search for a word to see if it was successful or not.
    
Let's say server response is one of:
<html><body>Thanks for voting<body><html>
or
<html><body>An error occured<body><html>
    
s: read http://vote.com/vote=Gayle+Winters
    
either find s "error" [
     alert "Error!"
] [
     alert "Success!"
]


posted by:   Endo       8-Aug-2013/18:50:34-7:00



I did:
    
either find voteSite "successfully" [
     alert "Voted!"
][
     alert "Error!"
]
    
And I got "Voted!"


posted by:   Gus       8-Aug-2013/21:47:54-7:00