AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[function] httpQuery GET and POST requests - update 0.3.4
Goto page Previous  1, 2, 3, 4  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  

Should a more generic function be released which will include the already available web functions, such as header queries, uri encoding, base encoding, etc ?
yes, i'd like to have one function to get all neccessary http functionalities in one instead of collecting each for my own
95%
 95%  [ 23 ]
no, i prefer collecting the functions i need
0%
 0%  [ 0 ]
neither nor ... explained in post
4%
 4%  [ 1 ]
Total Votes : 24

Author Message
ahklerner



Joined: 26 Jun 2006
Posts: 1249
Location: USA

PostPosted: Sat Jul 12, 2008 4:15 am    Post subject: Reply with quote

it should be
Code:
POSTdata := "logonid=" . login . "&password=" . pass

_________________

ʞɔпɟ əɥʇ ʇɐɥʍ
Back to top
View user's profile Send private message
bigsalgo911



Joined: 02 Jul 2008
Posts: 29

PostPosted: Sat Jul 12, 2008 4:34 am    Post subject: Reply with quote

OMG I would have NEVER figured that out. I haven't seen syntax like that. Is there a good tutorial for stuff like that?
Back to top
View user's profile Send private message
ahklerner



Joined: 26 Jun 2006
Posts: 1249
Location: USA

PostPosted: Sat Jul 12, 2008 4:46 am    Post subject: Reply with quote

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.
_________________

ʞɔпɟ əɥʇ ʇɐɥʍ
Back to top
View user's profile Send private message
rani



Joined: 18 Mar 2008
Posts: 95

PostPosted: Sat Jul 12, 2008 9:19 am    Post subject: httpRequest Reply with quote

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
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 1033

PostPosted: Sat Jul 12, 2008 1:21 pm    Post subject: Reply with quote

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
http://www.devx.com/DevX/Tip/17500
_________________
Read this
Com
Automate IE7 with Tabs
Back to top
View user's profile Send private message
DerRaphael



Joined: 23 Nov 2007
Posts: 604
Location: 127.0.0.1

PostPosted: Fri Jul 18, 2008 4:37 pm    Post subject: Reply with quote

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!
_________________
Back to top
View user's profile Send private message
DerRaphael



Joined: 23 Nov 2007
Posts: 604
Location: 127.0.0.1

PostPosted: Fri Jul 25, 2008 1:30 pm    Post subject: Reply with quote

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
_________________
Back to top
View user's profile Send private message
offline Seatbelt99
Guest





PostPosted: Sat Jul 26, 2008 3:04 am    Post subject: Reply with quote

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:Password@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%.
Back to top
tank



Joined: 21 Dec 2007
Posts: 1033

PostPosted: Sat Jul 26, 2008 5:21 am    Post subject: Reply with quote

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
_________________
Read this
Com
Automate IE7 with Tabs
Back to top
View user's profile Send private message
DerRaphael



Joined: 23 Nov 2007
Posts: 604
Location: 127.0.0.1

PostPosted: Sat Jul 26, 2008 10:11 am    Post subject: Reply with quote

offline Seatbelt99 wrote:
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 Smile
offline Seatbelt99 wrote:

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

I tried the http://Username:Password@www.example.com 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
Code:
<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)
http://www.autohotkey.com/forum/posting.php?mode=quote&p=210138&sid=12345678901234567890

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
_________________
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 1033

PostPosted: Sat Jul 26, 2008 2:33 pm    Post subject: Reply with quote

DerRaphael wrote:
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
http://w3schools.com

for ie a dom inspector
and an easier way to disect a web page
http://www.microsoft.com/downloads/details.aspx?familyid=E59C3964-672D-4511-BB3E-2D5E1DB91038&displaylang=en#Instructions

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

Code:
 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
_________________
Read this
Com
Automate IE7 with Tabs
Back to top
View user's profile Send private message
skrommel



Joined: 30 Jul 2004
Posts: 181

PostPosted: Sun Jul 27, 2008 12:35 am    Post subject: Reply with quote

Smile Just what I needed, DerRaphael!

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

Sad However, I'm having trouble with [url]PasteBin.com[/url], 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
_________________
www.1HourSoftware.com
Back to top
View user's profile Send private message Visit poster's website
DerRaphael



Joined: 23 Nov 2007
Posts: 604
Location: 127.0.0.1

PostPosted: Sun Jul 27, 2008 2:22 am    Post subject: Reply with quote

these are the header i received after submitting some data to pastebin

Quote:

(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 http://pastebin.com/d1b939d5c
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
_________________
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 1033

PostPosted: Sun Jul 27, 2008 2:53 am    Post subject: Reply with quote

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
_________________
Read this
Com
Automate IE7 with Tabs
Back to top
View user's profile Send private message
skrommel



Joined: 30 Jul 2004
Posts: 181

PostPosted: Sun Jul 27, 2008 8:13 am    Post subject: Reply with quote

Smile Thank's guys, but don't lose any sleep over this unless it's a common problem.

Skrommel
_________________
www.1HourSoftware.com
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4  Next
Page 2 of 4

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group