Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[function] httpQuery GET and POST requests - update 0.3.6


  • Please log in to reply
96 replies to this topic

Poll: Should a more generic function be released which will include the already available web functions, such as header queries, uri encoding, base encoding, etc ? (158 member(s) have cast votes)

Should a more generic function be released which will include the already available web functions, such as header queries, uri encoding, base encoding, etc ?

  1. yes, i'd like to have one function to get all neccessary http functionalities in one instead of collecting each for my own (174 votes [96.67%])

    Percentage of vote: 96.67%

  2. no, i prefer collecting the functions i need (5 votes [2.78%])

    Percentage of vote: 2.78%

  3. neither nor ... explained in post (1 votes [0.56%])

    Percentage of vote: 0.56%

Vote Guests cannot vote
ahklerner
  • Members
  • 1386 posts
  • Last active: Oct 08 2014 10:29 AM
  • Joined: 26 Jun 2006
it should be
POSTdata := "logonid=" . login . "&password=" . pass

Posted Image
ʞɔпɟ əɥʇ ʇɐɥʍ

bigsalgo911
  • Members
  • 29 posts
  • Last active: Jul 12 2008 04:34 AM
  • Joined: 02 Jul 2008
OMG I would have NEVER figured that out. I haven't seen syntax like that. Is there a good tutorial for stuff like that?

ahklerner
  • Members
  • 1386 posts
  • Last active: Oct 08 2014 10:29 AM
  • Joined: 26 Jun 2006
your syntax would have been perfect had you used '=' instead of ':=' ... '=' assigns a string and ':=' is an expression. inside of expressions strings are quoted and variable names are not surrounded with percent signs. the ' . ' around the variables can be reduced to ' ' (a single space) but is not recommended as the behavior may change in future versions.

i think there is a good post for that, but I am not sure. hopefully someone else knows the name as the search does not help me find it.
Posted Image
ʞɔпɟ əɥʇ ʇɐɥʍ

rani
  • Members
  • 217 posts
  • Last active: Jul 21 2016 12:53 PM
  • Joined: 18 Mar 2008
I tried the dll, via the AHK:

http := COM_CreateObject("Msxml2.XMLHTTP.4.0")

it's the native dll I think for ajax (xmlhttprequest)
it gave the whole http request/rsponse as from standard html page.

and all it's commands work perfect
got good response from server.

rgrds
ell

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
as a heavy ajax script user in professional life. i can tell you such documentation is in very scarce supply almost all instances found on the web use get instead of post data
below is the best example i can find but no there isnt really any good documentation to be had
<!-- m -->http://www.devx.com/DevX/Tip/17500<!-- m -->
Never lose.
WIN or LEARN.

derRaphael
  • Members
  • 872 posts
  • Last active: Mar 19 2013 04:42 PM
  • Joined: 23 Nov 2007
new httpQuery Version release. version 0.3.1 is now online and includes many new features and bugfixes. Please update all your given example codes and your scripts, since the syntax has changed by introducing binary downloads which need to be adressed with byref parameters.

thanks!

All scripts, unless otherwise noted, are hereby released under CC-BY

derRaphael
  • Members
  • 872 posts
  • Last active: Mar 19 2013 04:42 PM
  • Joined: 23 Nov 2007
a minor update. the current version 0.3.2 supports a new HttpQueryOps Verb called "updateSize". using this will make two Variables available at runtime: HttpQueryFullSize and HttpQueryCurrentSize. Knowing these two values allows it easily to include a Progress bar to indicate current download status.

greets
DerRaphael

All scripts, unless otherwise noted, are hereby released under CC-BY

offline Seatbelt99
  • Guests
  • Last active:
  • Joined: --
ok - I'm a noob and this is VERY useful to me, and amazing, I have been trying to learn cURL for a couple weeks now, and this I am already picking up since this morning. Excellent job.

That being said...

Could someone explain how I could log into a site using this.

I tried the http://Username:Pass...www.example.com that someone posted, and also tried copying the PostData that I got from tamper data when logging in, neither worked.

Any help would improve my life by about 73%.

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
read all of the posts in this thread its already answered
almost no web site allows you to log in ftp style
you need to use post data or a query string to submit your username and password
Never lose.
WIN or LEARN.

derRaphael
  • Members
  • 872 posts
  • Last active: Mar 19 2013 04:42 PM
  • Joined: 23 Nov 2007

ok - I'm a noob and this is VERY useful to me, and amazing, I have been trying to learn cURL for a couple weeks now, and this I am already picking up since this morning. Excellent job.

That being said...

Thank you very much :)

Could someone explain how I could log into a site using this.

I tried the <!-- m -->http://Username:Pass...www.example.com<!-- m --> that someone posted, and also tried copying the PostData that I got from tamper data when logging in, neither worked.


the thing is, that when using the username:password URL syntax it only works, when a site pop ups a little window (from browser, not a custom html with pictures or funky text etc) to with no extra text just asking for username and password login.

technically this is ususally realised thru .htaccess files on the server which need special login credentials to allow the access to particular data.

the much more common case, such as loging in to a webmail account or for example to autohotkey.com/forum is that u need to enter your username and your password in a webpage (compare the login in button here in forum to see an example).

now, to make httpQuery (or any other POST sending function) work in such cases u need to find out what the input fields are named. There are many attempts on how to do that.

either (if your know how to read HTML) you might peek the sourcecode of the page and have a look for the
<form action="someaddress"> ... </form>
tags and look for the <input> Tags (which is actually pretty easy) u just need to know how a form is build with html. input tags usually have an attribute "name" like <Input type=text name="firstname"> so an appropriate post would look like PostData:="firstname=whateveriliketosendhere".
There are also <TextArea name="whatever"></textarea> tags and <select name="something"><option value="x">text X</option></select> style tags. their usage is much the same ... they have a name which needs to be lefthand of the POSTdata parameter and a possible value. that is either the content of the <Option> tags if no Value attribute given or the value attribute. when u see an input type="hidden" these need to be in the Postdata aswell, an <input type=checkbox> only needs to be set when u want to be the value known as checked. in this case its either ON or Off. The Last thing (some webmaster do this to prevent user using automatisms) is that the <input type=submit> button may contain a name and a value. in this case it would get transmitted aswell.

maybe someone is willing to modify my given example for extracting formdata and release a version which also drops a proper AHK scrippet ready to use.

if this is too complicated (which i can understand, when u're not familiar with HTML) and u want to use a more UserInterface guided variant, there is a plugin called HttpFox for firefox, which allows to inspect which values (including Cookies and all neccessary POSTdatas) are send to your target webpage. it has a Tab calles POSTdata showing two rows - the name of the value and its content. (aright above the tabs is a list of which browser action to inspect - look for these saying type is POST) u can select all the rows and use it for your script.
when your using InternetExplorer, there might be a workaround ... save the webpage to your local harddisk, edit the sourcecode (the *.html file) and change in all <form> Tags method="post" to method="get".
Filling out the new modified form will bring show your an funny looking URL: (somewhat similar to this)
<!-- m -->http://www.autohotke... ... 1234567890<!-- m -->

all the parts after the questionmark are the Data which would have been send via POST so just copy from questionmark on (exluding it) and put these into your postdata variable.

i hope this lil exscusrsion helps a bit

greets
DerRaphael

All scripts, unless otherwise noted, are hereby released under CC-BY

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007

when your using InternetExplorer, there might be a workaround ... save the webpage to your local harddisk, edit the sourcecode (the *.html file) and change in all <form> Tags method="post" to method="get".

For those needing to learn more about HTML DHTML
Javascript and more
<!-- m -->http://w3schools.com<!-- m -->

for ie a dom inspector
and an easier way to disect a web page
<!-- m -->http://www.microsoft... ... structions<!-- m -->

very cool and free for now
one more thing
in your address bar try going to said log in page and filling it but not clicking your button
not all forms are visible fortuantely log in screens are usually pretty straght forward
use this in the address bar

javascript:var x=document.forms.length; for (i=0;i < x;++i){document.forms(i).method='get'};void(0)
much easier way to setting all the forms on the page to use get instead
easy to get a query string now
Never lose.
WIN or LEARN.

skrommel
  • Members
  • 193 posts
  • Last active: Jun 07 2010 08:30 AM
  • Joined: 30 Jul 2004
:) Just what I needed, DerRaphael!

I use Fiddler from http://www.fiddler2.com/fiddler2 to catch the web traffic, if anyone is interested.

:( However, I'm having trouble with PasteBin.com, a page for posting source code.

httpQuery posts just great, but it returns a 404, probably because the page changes url. Is there a way to catch this? WGET does...

Skrommel

derRaphael
  • Members
  • 872 posts
  • Last active: Mar 19 2013 04:42 PM
  • Joined: 23 Nov 2007
these are the header i received after submitting some data to pastebin

(Status-Line) HTTP/1.1 302 Found
Date Sun, 27 Jul 2008 02:17:44 GMT
Server Apache/1.3.33 (Debian GNU/Linux) mod_python/2.7.10 Python/2.3.4 PHP/4.3.10-22 mod_perl/1.29
X-Powered-By PHP/4.3.10-22
Location <!-- m -->http://pastebin.com/d1b939d5c<!-- m -->
Keep-Alive timeout=15, max=100
Connection Keep-Alive
Transfer-Encoding chunked
Content-Type text/html; charset=iso-8859-1


i'll recheck later ... but it seems that pastebin drops the target URL in a location line which could be captured with store Header ...

i'll try an example later

edit some quick test showed that the header received with httpQuery returns the 404 .... seems like it tries to access the location before it gets created or something alike ... i'll dig this ... but for now i gotta go to bed its almost 5 am here ... and im getting too tired to code some more

greets
DerRaphael

All scripts, unless otherwise noted, are hereby released under CC-BY

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
some sites accept only post OR get not both its not very common any more so it might be related i hdavent bothered to check this particular site out
but google for instance only accepts get not post
Never lose.
WIN or LEARN.

skrommel
  • Members
  • 193 posts
  • Last active: Jun 07 2010 08:30 AM
  • Joined: 30 Jul 2004
:) Thank's guys, but don't lose any sleep over this unless it's a common problem.

Skrommel