I am creating an online database, So I need to connect to a webpage, read the first line, open another connection, fill in some data, and then go to the second, and so on.
et url "http://localhost/akicks/todo.php"
set trigger "!test"
if {![info exists egghttp(version)]} {
putlog "egghttp.tcl was NOT successfully loaded."
putlog "http-akicks.tcl has not been loaded as a result."
} else {
proc your_callbackproc {sock} {
global url
set headers [egghttp:headers $sock]
set body [egghttp:data $sock]
foreach line [split $body \n] {
regsub -all -nocase {<br>} $line "" line
regsub -all -nocase {<b>} $line "" line
regsub -all -nocase {</b>} $line "" line
set id [lindex $line 0]
set secondline [string trimleft $line $id]
set com [lindex $secondline 0]
set newurl "http://localhost/akicks/mark.php?id=$id&com=$com&pass=12ledro"
set sockset [egghttp:geturl $newurl akick_proc]
return 1
}
proc akick_proc {sock} {
set headersset [egghttp:headers $sockset]
set bodyset [egghttp:data $sockset]
foreach line [split $body \n]
if {$bodyset == "Ok"} {
putlog "success"
}
}
}
bind dcc o|o $trigger our:dcctrigger
bind pub o|o $trigger our:pubtrigger
proc our:dcctrigger {hand idx text} {
global url
set sock [egghttp:geturl $url your_callbackproc]
return 1
}
proc our:pubtrigger {nick host hand chan arg} {
global url
set sock [egghttp:geturl $url your_callbackproc]
return 1
}
putlog "http-akicks.tcl has been successfully loaded."
}
But this only seems to work for the first line. Any suggestions?
The http package is well documented in the tcl man pages.. There's also a thousand example scripts here and in the archives (all of my webscripts use the http package, a few use the socket code, none use egghttp.tcl)