help with visit_url

I cannot for the life of me figure out what exactly I'm doing wrong, but I'm having trouble in a few places where visit_url isn't returning anything, no matter how I call it.

Code:
 string p="inv_booze.php?pwd="+my_hash()+"&which=1&whichdrink="+bev;
 string res=visit_url(p);
 res=visit_url(p,false,false);
 res=visit_url(p,true,true);
 res=visit_url(p,false,true);
Where bev is just a number in a string (for instance, 6512)

For testing, I don't have the drink, but when I make a link and click it with exactly that format, I get a "You don't have that item" page along with inventory. Via visit_url(), however, I get no result of any kind.

For what it's worth, this is in a relay script (custom, not override).

I've tried it without manually entering the hash, and with, and even with it in other spots amongst the parameter (the wiki suggests that pwd as the first parameter doesn't get auto-filled in by the interpreter)

I also had this problem with using Instant Karma, but I just gave up on gathering the result and used this ugly gem:
Code:
 while(item_amount($item[Instant Karma])>0)cli_execute("text inventory.php?which=1&action=discard&pwd&whichitem=4448");
So, the "equivalent" in CLI works, but not with visit_url().
 

Veracity

Developer
Staff member
Code:
string p="inv_booze.php?pwd="+my_hash()+"&which=1&whichdrink="+bev;
I'm not surprised that inv_booze doesn't like the URL, since you didn't give it an item ID. Try

Code:
string p="inv_booze.php?pwd&which=1&whichitem="+bev;
You don't need to specify the page. You don't need your password hash. You can specify the quantity. You can specify "ajax=1" to get a simpler page of HTML in return. So, you could also do the following:

Code:
string p="inv_booze.php?quantity=1&ajax=1&whichitem="+bev;
 
Code:
string p="inv_booze.php?pwd="+my_hash()+"&which=1&whichdrink="+bev;
I'm not surprised that inv_booze doesn't like the URL, since you didn't give it an item ID. Try

Code:
string p="inv_booze.php?pwd&which=1&whichitem="+bev;
You don't need to specify the page. You don't need your password hash. You can specify the quantity. You can specify "ajax=1" to get a simpler page of HTML in return. So, you could also do the following:

Code:
string p="inv_booze.php?quantity=1&ajax=1&whichitem="+bev;

I cannot believe I didn't notice in like... 200 times going back and forth between link and visit_url() that one said "drink" and one said "item"... I feel like a dolt.

As for ajax=1... about -how- simple is it? Like, just the relative bit of info regarding the drinking action?

EDIT:
made the changes, currently:
Code:
 string p="inv_booze.php?quantity=1&whichitem="+bev;
 string res=visit_url(p);
...
 string p="inv_booze.php?quantity=1&ajax=1&whichitem="+bev;
 string res=visit_url(p);
Both still result in a big fat nothing.
 
Last edited:

Veracity

Developer
Staff member
Well, what the heck. Put in the "&pwd". When I looked at a debug log of KoLmafia submitting a request to use a drink, it was not there, but the link on the inventory page does have it.
 
I'm gonna have to say there is something fishy going on with the way visit_url works in a relay script (... again...)
I took the exact code, changed the write() to print(), saved it as a "normal" script. Drank the booze and loaded the page without a problem.

Of course, being a loather of Java, my diagnostic ability ends here.
 
Top