egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

HTTP misunderstandings!

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Neeq
Voice


Joined: 01 Mar 2007
Posts: 8

PostPosted: Mon Jun 02, 2008 10:22 am    Post subject: HTTP misunderstandings! Reply with quote

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
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Mon Jun 02, 2008 10:47 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
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


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber