This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

"Reading" a PHP-Query

Old posts that have not been replied to for several years.
Locked
S
Spirit
Voice
Posts: 15
Joined: Sat Oct 11, 2003 5:57 am

"Reading" a PHP-Query

Post by Spirit »

Hi @ll!

I got a php-site, which searches a mysql-db and sends me the results as simple text back.
Is it possible to connect with the eggdrop to the page, get the results and post them into a channel?

The URL looks like this: http://www.website.com/ircquery.php?pas ... ch&param=B

And the results are looking like this:
Bad Boy
Bomber
...


It makes a "B*" search in the database.
it's not a bug - it's a feature!
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

Code: Select all

set result [::http::data [set tok [::http::geturl http://www.website.com/ircquery.php?pass=secret&select=search&param=B]]]
::http::cleanup $tok
#$result conatins the results
Elen sila lúmenn' omentielvo
S
Spirit
Voice
Posts: 15
Joined: Sat Oct 11, 2003 5:57 am

Post by Spirit »

Thx Papillon!

Unfortuantely i am not getting any results back. Just for the testing i am posting the results in a dummychan right away.

Code: Select all

proc pub_!getresult {nick uhost hand chan rest} {
  set result [::http::data [set tok [::http::geturl http://www.website.com/ircquery.php?pass=secret&select=search&param=B]]]
 putchan $chan $result
 ::http::cleanup $tok
}
bind pub - !getresult pub_!getresult
The bot is posting, when i fill $result by hand and i get results when i enter the URL in the IE
it's not a bug - it's a feature!
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

is there an error on the partyline ?
and : have you loaded egghttp.tcl ?
S
Spirit
Voice
Posts: 15
Joined: Sat Oct 11, 2003 5:57 am

Post by Spirit »

Yep ..egghttp.tcl is loaded, but after your post ;)
Didn't know i need that script *sorry*

Now there is a error:

Code: Select all

Tcl error [pub_!getresult]: invalid command name "::http::geturl"
it's not a bug - it's a feature!
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

i dont work that much with http scripts, but try using the egghttp:geturl proc instead
S
Spirit
Voice
Posts: 15
Joined: Sat Oct 11, 2003 5:57 am

Post by Spirit »

Ok now i get a little further (by using the egghttp.tcl), and there is always this message:

Code: Select all

net: connect! sock 6
net: eof!(read) socket 6
by using this code:

Code: Select all

proc pub_!bsd {nick uhost hand chan rest} {
 set sock [egghttp:geturl http://www.website.com/ircquery.php?pass=secret&select=search&param=B get_results]
}
bind pub - !bsd pub_!bsd

proc get_results {sock} {
   set buffer [egghttp:data $sock]
   egghttp:cleanup $sock
   putlog $buffer
}
I used the example at the end of the script and made sure, that there are any results
it's not a bug - it's a feature!
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

Papillon gave the code snippet, so he may want to answer the question. But likely you need to use http.tcl that ships with tcl (directory http2.4).
S
Spirit
Voice
Posts: 15
Joined: Sat Oct 11, 2003 5:57 am

Post by Spirit »

Thx alot egghead!!
I didnt know, where to find that tcl. I used tho old code from Papillon and now it works :o)

Thx all for your help!
it's not a bug - it's a feature!
Locked