Make url

From Kolmafia
Revision as of 09:14, 27 April 2011 by imported>Bale (function added in r8940. Not very useful, but it should be on the wiki anyway.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Function Syntax

buffer make_url(string page ,boolean use_POST ,boolean encoded )

  • page is the page to visit
  • use_POST is true for a POST request and false for a GET request
  • encoded If set to true, then the url is assumed to be pre-encoded by the user.

Returns the url that would be visited if this was a visit_url(). This function was intended for troubleshooting crafted urls and has no use outside of debugging purposes.

Code Samples

Compares the URL you expect to visit with the URL that you are actually visiting. This was once useful.

buffer mbuf;
mbuf.append( "pickpocket\n" );
mbuf.append( "attack\n" );
mbuf.append( "repeat" );

string macro = mbuf.to_string();

buffer new_url;
new_url.append( "fight.php" );
new_url.append( "?" );
new_url.append( "action=macro" );
new_url.append( "&" );
new_url.append( "macrotext=" );
new_url.append( macro );

print( "crafted unencoded url = \"" + new_url + "\"");
print( "submitted url = \"" + make_url( new_url, true, false ) + "\"" );

See Also

visit_url()