| View previous topic :: View next topic |
| Author |
Message |
Neeq Voice
Joined: 01 Mar 2007 Posts: 8
|
Posted: Mon Jun 02, 2008 10:22 am Post subject: HTTP misunderstandings! |
|
|
Hey guys,
I've been learned TCL on and off for a while and decided to have a go at tcl::http, but I have hit a brick wall and the documentation isn't the clearest thing in the world.
What I want to do is have the script access a page ( example: http://ex.com/?add ), then use POST to send data.
I have looked at the documentation for it but didn't really find any clues other than basic examples of ::http::geturl.
Any help will be appreciated. |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Mon Jun 02, 2008 10:47 am Post subject: |
|
|
Well, this would be accomplished in a few steps:
1st, use ::http:geturl to retrieve the page:
| Code: | | set token [::http::geturl $url] |
2nd, get the content, and parse it if necessary :
| Code: | set data [::http::data $token]
#parse $data and so on... |
3rd, construct the query to be sent with your POST:
| Code: | | set q [::http::formatQuery key1 value1 key2 value2] |
4th, use ::http::geturl to POST the new query:
| Code: | | set token2 [::http::geturl $url -query $q] |
5th, get the content
| Code: | | set data2 [::http::data $token2] |
Since you are running this under eggdrop, it would be advisable to use the callback function of geturl, as to prevent your eggdrop from freezing.
Also, this was a very lazy example, where I simply assume the http-transaction went by flawlessly, and thus do not check for any errors or such. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|