AutoHotkey Community

It is currently May 27th, 2012, 6:46 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 228 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7 ... 16  Next
Author Message
 Post subject:
PostPosted: August 23rd, 2011, 12:26 pm 
Offline
User avatar

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
You forgot the quotes:
Code:
httprequest("us.battle.net/api/wow/auction/data/medivh", inOutPost, inOutHeaders, "")


You might want to read the AutoHotkey manual entry on expressions.

_________________
fincs
Highly recommended: AutoHotkey_L (see why) (all my code snippets require it)
Formal request to polyethene - I support the unity of the AutoHotkey community
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 23rd, 2011, 1:45 pm 
Plqk wrote:
I am trying to fetch WoW (World of Warcraft) armoury data with HTTPrequest. It should be just as simple as:
Code:
httprequest(us.battle.net/api/wow/auction/data/medivh, inOutPost, inOutHeaders, "")


Unfortunately I am getting the following error: "There was problem with the provided URL(InternetCrackURL). ErrorLevel = 0, A_LastError = 12006"


Try this:

Code:
httprequest("us.battle.net/api/wow/auction/data/medivh", inOutPost, inOutHeaders, "")


Strings in expressions need to be enclosed in quotes.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 23rd, 2011, 2:43 pm 
Offline

Joined: July 8th, 2011, 7:24 pm
Posts: 17
Sorry I mislead you a bit... in my code I have it in quotes (I was not directly pasting the code). I still get the error.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Nice script
PostPosted: August 23rd, 2011, 5:54 pm 
Offline

Joined: March 16th, 2008, 6:48 pm
Posts: 161
Location: Brooklyn
Firstly, thanks [VxE] for making and maintaining this script.

I hate to ask the beginner question, but is it possible to see an example of something else (which is simpler)? It is the equivalent of URLDownloadToFile, but with a name and password.

In my case, I want to pull back information from eBay.com, but any site will do. For eBay, I know that the POSTDATA for the User name & Password is 'userid' & 'pass'. Any page is good, I just don't know exactly how to set it up.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 23rd, 2011, 7:42 pm 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3330
Location: Simi Valley, CA
YW, Sergio. I don't have an example specific to the eBay website (different from eBay's API), but here are a tip for beginners using HTTPRequest.

Tip: Setting up the HTTPRequest call:
Code:
; Users are encouraged to utilize continuation sections for readability.
My_URL = https://www.mysecuresite.com/login?dologin=1
My_POST =
( LTRIM C JOIN& ; Join using an ampersand to separate name/value pairs in the forms POST data
    userid=%myuserid%
    pass=%mypassword% ; variable references depend on the assignment operator ( '=' v.s. ':=' )
)
My_Headers =
( LTRIM ; join headers using regular newlines (the default join character).
    my-auth-type: auth-post
    Content-Type: application/x-www-form-urlencoded
)
My_Options =
( LTRIM C ; options should also be separated by newlines.
    +Flag: INTERNET_FLAG_NO_COOKIES
    Callback: MyProgressFunc
)
; Call HTTPRequest. For debugging purposes, copy the POST data (if it is text) to the variable that is going to hold the response.
; If not submitting POST, assign an empty string to the variable that will hold the response.
size := HTTPRequest( My_URL, My_Response := My_POST, My_Headers, My_Options )


A number of bugs and (un)desirable behaviors have been brought to my attention (many thanks, mauritius and dadepp) and I am working on addressing most of them for the next version of HTTPRequest, which I hope to release in the next week or two. The updates should increase usability in cases involving file downloads and codepages other than UTF and english, and it will address problems with the format of the options parameter.

_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 24th, 2011, 7:48 am 
Offline

Joined: July 8th, 2011, 7:24 pm
Posts: 17
Plqk wrote:
Sorry I mislead you a bit... in my code I have it in quotes (I was not directly pasting the code). I still get the error.


Got it to work... forgot I was behind a proxy.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 6th, 2011, 4:56 pm 
Can this be adapted to accept other ports than the default (80, 443)?

Other than that, great library. 8)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 6th, 2011, 6:27 pm 
Offline

Joined: July 6th, 2011, 5:37 pm
Posts: 214
Location: Looking over my domain
n-l-i-d wrote:
Can this be adapted to accept other ports than the default (80, 443)?

Other than that, great library. 8)
Sorry if I am incorrect but isn't the port part of the URL and left out for the defaults of the protocols

Thanks

_________________
Image Stolen from SKAN


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 6th, 2011, 8:58 pm 
Offline
User avatar

Joined: August 23rd, 2010, 6:22 pm
Posts: 781
Location: Ontario, Canada
Yes, it is possible with URL's in the following format:

Code:
SCHEMA://DOMAIN.TLD:PORT/


Where "PORT" is the port number.

_________________
AutoHotkey.net | GitHub

My default license.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 7th, 2011, 7:39 am 
Hmm, ok, must be an error on my part then.

Thanks.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 11th, 2011, 8:07 am 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3330
Location: Simi Valley, CA
Thanks daonlyfreez and Uberi, I learned something new :lol:

And, here is the long-awaited update: version (9-10-2011).

BugFix: Options parsing.

BugFix: MD5 function now returns the base64 encoded hash. Also, the automatic value for the Content-MD5 header should be correct for the actual POST data even if uploading a file or after codepage conversion.

New Option: Binary: tells HTTPRequest not to do anything special to downloaded text (no codepage conversion).

New Option: Codepage: tells HTTPRequest to convert the POST text to the codepage specified in the 'charset' attribute of the 'Content-Type' request header.

New Option: Upload: (filepath): HTTPRequest will upload the file as POST data, INSTEAD of whatever is in the 'in_POST_out_Data' parameter.

Tweaked Option: Callback: (Function Name)[, param3]: previously, the callback function had to require either one or two parameters. Now the function may require between 0 and 3 parameters. If the function accepts a third parameter, whatever text appears after the name of the callback function is passed as the third parameter.

Tweak: If the callback function returns the word "cancel", HTTPRequest will terminate the transaction, clean up, and return the number of bytes downloaded.

Tweaked Option: [N][R]> (output file): Two modifiers for the output file option change how the download is handled. The 'N' modifier prevents HTTPRequest from reading the file's contents into 'in_POST_out_Data' (convenient for large downloads). The 'R' option is a shortcut for the Range: header, and IF the file exists, HTTPRequest will attempt to resume downloading it.

Tweak: Cookie headers no longer need +INTERNET_FLAG_NO_COOKIES specified in the options.

Tweak: Options flags no longer need the word 'flag:' in front, a single '+' or '-' tells HTTPRequest to look at the option as a flag.

A note about resuming the download: I had considered following dadepp's example more closely and implemented more stringent validity checks. In the end, I decided just to check for the '206 Partial Content' response code before writing to the file.

As always, let me know if you find any bugs.

_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 11th, 2011, 5:19 pm 
Offline

Joined: March 16th, 2005, 10:33 pm
Posts: 969
Location: Frisia
Is somebody willing to test this lib with SABnzbd, a client for that which shall not be mentioned.

It listens on port 8085, and for some weird reason, I cannot connect to it with the lib. SABnzbd has an API, which can be used to control it.

A simple test would be to return the version. For this you do not need the API key (can be found in the program's settings):

Code:
searchurl := "http://localhost:8085/sabnzbd/api?mode=version&output=xml"

msgbox % len := HTTPRequest(searchurl, resultData, resultHeaders) . "`n`n" . resultHeaders . "`n`n" . resultData


I get a MsgBox with the following error:

Quote:
0

There was a problem sending the GET request. ErrorLevel = 0, A_LastError = 12029


I don't get why it doesn't work as expected. :(

Anybody?

_________________
Image mirror 1mirror 2mirror 3ahk4.me • PM or Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 24th, 2011, 11:19 am 
Offline

Joined: January 8th, 2007, 1:14 pm
Posts: 83
@daonlyfreez

I've got no problems getting response. Using latest AHK_L with SABnzbd version 0.6.9. Apart from having APIKEY defined and different host address, it worked on my first try. :shock:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 26th, 2011, 4:34 pm 
@Mystic: thanks for trying.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 27th, 2011, 4:18 pm 
Offline

Joined: December 7th, 2005, 8:29 am
Posts: 345
Can someone post a POST example for this URL:
http://www.w3schools.com/webservices/te ... tToCelsius

And can we use multiple flags, when calling the functions?

Thanks,
Twhyman

_________________
(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 228 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7 ... 16  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, jepjep24 and 17 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group