AutoHotkey Community

It is currently May 26th, 2012, 10:03 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 233 posts ]  Go to page Previous  1 ... 6, 7, 8, 9, 10, 11, 12 ... 16  Next

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
no, i prefer collecting the functions i need
neither nor ... explained in post
You may select 1 option

View results
Author Message
PostPosted: September 26th, 2009, 5:49 pm 
This is a great script, but I can't get https to work. Is there something I'm missing? Here is my simple code.

Code:
#Include httpQuery.ahk

URL := "https://www.changeip.com/nic/update?u=username&p=password&cmd=update&set=1&offline=0"

httpQuery(raw, URL)
VarSetCapacity(raw, -1)

MsgBox % raw


Looking at the host hit records, the hit never happens and the raw var is empty. Making the same clal over http works fine.


Report this post
Top
  
Reply with quote  
 Post subject: Not work with HTTPS
PostPosted: October 13th, 2009, 4:09 pm 
Yes, I have the same problem with https (raw var is empty).
Anyone can help us?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 13th, 2009, 10:00 pm 
Offline

Joined: December 17th, 2008, 5:36 am
Posts: 80
I am not having any problems with the script its self everything works great, Kudos to the op.

I see that it says it has a timeout function. I can't for the life of me figure out how to configure it. Is it just using a Microsoft timeout feature that is not configurable? How do I interact with it?

Also, how could I implement a stop button to stop the current load? i tried using a timer that polls a variable connected to a check box but haven't had much success. Keep in mind I don't really know how this script works but I assumed if I interrupted it with timer and reloaded the variable URL with a blank address it would in essence stop what it was doing. This however did not work, big surprise. (Code below)

Code:
interupt:
if(stopcurrentload = 1)
{
   URL := ""
   length := httpQuery(dlwebsite, URL)
   varSetCapacity(dlwebsite,-1)
}
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 14th, 2009, 12:29 am 
Offline

Joined: December 4th, 2006, 10:35 am
Posts: 561
Location: Galil, Israel
you'll have to add in code to check for a var, and set that var to 'stop'. there are other examples for other scripts, searchable. (sorry don't remember off hand where).

_________________
Joyce Jamce


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 14th, 2009, 8:44 am 
Offline

Joined: December 7th, 2005, 8:29 am
Posts: 345
Hi,

Does any one knows how to use httpquery to post SOAP XML requests?

This what the webservice need:
Code:
POST /PingWebService.asmx HTTP/1.1
Host: app-server
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://kcs.koko/PingWindowsService"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <PingWindowsService xmlns="http://kcs.koko/" />
  </soap:Body>
</soap:Envelope>


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  
 Post subject:
PostPosted: October 16th, 2009, 7:55 am 
Offline

Joined: November 27th, 2008, 9:44 am
Posts: 62
I've got a bunch of books I'm trying to unload, and half.com (ebay) has an XML API where i can automatically list them.

I've been reading through their docs and playing with httpQuery, but I can't seem to effectively translate what they call their "hello world" to AHK using httpQuery. I've included the perl i'm trying to translate in the code below.

(and yes, i appropriately replaced all the BLAHBLAHBLAH sections, but the httpQuery function keeps returning -1 (and yes, it's probably something really stupid that i'm over looking :( ))

thanks for taking a look!

Code:
; define the HTTP headers
headers =
(Ltrim
   X-EBAY-API-COMPATIBILITY-LEVEL: 391
   X-EBAY-API-DEV-NAME: BLAHBLAHBLAH
   X-EBAY-API-APP-NAME: BLAHBLAHBLAH
   X-EBAY-API-CERT-NAME: BLAHBLAHBLAH
   X-EBAY-API-CALL-NAME: GeteBayOfficialTime
   X-EBAY-API-SITEID: 0
   Content-Type: text/xml
)

; define the XML request
request =
(LTrim
   <?xml version='1.0' encoding='utf-8'?>"
   <GeteBayOfficialTimeRequest xmlns=\"urn:ebay:apis:eBLBaseComponents\">"
     <RequesterCredentials>"
       <eBayAuthToken>BLAHBLAHBLAH</eBayAuthToken>"
     </RequesterCredentials>"
   </GeteBayOfficialTimeRequest>
)

; request URL
url := "https://api.sandbox.ebay.com/ws/api.dll"

; send the request (returns -1)
msgbox % httpQuery(result:="", url, request, headers)

; blank
msgbox % result





; THE PERL CODE I'M TRYING TO TRANSLATE
/*
   use strict;
   use LWP::UserAgent;
   use HTTP::Request;
   use HTTP::Headers;
   
   # define the HTTP header
   my $objHeader = HTTP::Headers->new;
   $objHeader->push_header('X-EBAY-API-COMPATIBILITY-LEVEL' => '391');
   $objHeader->push_header('X-EBAY-API-DEV-NAME' => 'yourdevname');
   $objHeader->push_header('X-EBAY-API-APP-NAME' => 'yourappname');
   $objHeader->push_header('X-EBAY-API-CERT-NAME' => 'yourcertname');
   $objHeader->push_header('X-EBAY-API-CALL-NAME' => 'GeteBayOfficialTime');
   $objHeader->push_header('X-EBAY-API-SITEID' => '0');
   $objHeader->push_header('Content-Type' => 'text/xml');
   
   # define the XML request
   my $request =
       "<?xml version='1.0' encoding='utf-8'?>" .
       "<GeteBayOfficialTimeRequest xmlns=\"urn:ebay:apis:eBLBaseComponents\">" .
       "  <RequesterCredentials>" .
       "    <eBayAuthToken>TOKENGoesHERE</eBayAuthToken>" .
       "  </RequesterCredentials>" .
       "</GeteBayOfficialTimeRequest>";
   
   # make the call
   my $objRequest = HTTP::Request->new(
     "POST",
     "https://api.sandbox.ebay.com/ws/api.dll",
     $objHeader,
     $request
   );
   
   # deal with the response
   my $objUserAgent = LWP::UserAgent->new;
   my $objResponse = $objUserAgent->request($objRequest);
   if (!$objResponse->is_error) {
     print $objResponse->content;
   }
   else {
     print $objResponse->error_as_HTML;
   }
*/



Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 16th, 2009, 8:12 am 
Offline

Joined: July 9th, 2009, 9:25 pm
Posts: 120
Try this for request:
Code:
; define the XML request
request =
(LTrim
   <?xml version='1.0' encoding='utf-8'?>
   <GeteBayOfficialTimeRequest xmlns="urn:ebay:apis:eBLBaseComponents">
     <RequesterCredentials>
       <eBayAuthToken>BLAHBLAHBLAH</eBayAuthToken>
     </RequesterCredentials>
   </GeteBayOfficialTimeRequest>
)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 16th, 2009, 4:52 pm 
Offline

Joined: November 27th, 2008, 9:44 am
Posts: 62
temp01 wrote:
Try this for request:
Code:
; define the XML request
request =
(LTrim
   <?xml version='1.0' encoding='utf-8'?>
   <GeteBayOfficialTimeRequest xmlns="urn:ebay:apis:eBLBaseComponents">
     <RequesterCredentials>
       <eBayAuthToken>BLAHBLAHBLAH</eBayAuthToken>
     </RequesterCredentials>
   </GeteBayOfficialTimeRequest>
)


Ugh, there was indeed something stupid I was overlooking. But, I removed and unescaped the relevant quotes and it still just returns -1.

any thoughts? i'm in the dark here


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 17th, 2009, 5:28 am 
Offline

Joined: November 27th, 2008, 9:44 am
Posts: 62
I'm not really sure why it wasn't working, maybe something with the SSL?

Because i modified ahklerners UrlGetContents to accept headers (http://www.autohotkey.com/forum/viewtopic.php?p=303661#303661), and used it in my script, which now just works:

Code:
; define the HTTP headers
headers =
(Ltrim
   X-EBAY-API-COMPATIBILITY-LEVEL: 391
   X-EBAY-API-DEV-NAME: BLAHBLAHBLAH
   X-EBAY-API-APP-NAME: BLAHBLAHBLAH
   X-EBAY-API-CERT-NAME: BLAHBLAHBLAH
   X-EBAY-API-CALL-NAME: GeteBayOfficialTime
   X-EBAY-API-SITEID: 0
   Content-Type: text/xml
)

; define the XML request
request =
(LTrim
   <?xml version='1.0' encoding='utf-8'?>
   <GeteBayOfficialTimeRequest xmlns="urn:ebay:apis:eBLBaseComponents">
     <RequesterCredentials>"
       <eBayAuthToken>BLAHBLAHBLAH</eBayAuthToken>
     </RequesterCredentials>
   </GeteBayOfficialTimeRequest>
)

; request URL
url := "https://api.sandbox.ebay.com/ws/api.dll"

; using WININET and UrlGetContents instead of httpQuery
WININET_Init()
MsgBox % UrlGetContents(url, "", "", request, headers)
WININET_UnInit()





; THE PERL CODE I'M TRYING TO TRANSLATE
/*
   use strict;
   use LWP::UserAgent;
   use HTTP::Request;
   use HTTP::Headers;
   
   # define the HTTP header
   my $objHeader = HTTP::Headers->new;
   $objHeader->push_header('X-EBAY-API-COMPATIBILITY-LEVEL' => '391');
   $objHeader->push_header('X-EBAY-API-DEV-NAME' => 'yourdevname');
   $objHeader->push_header('X-EBAY-API-APP-NAME' => 'yourappname');
   $objHeader->push_header('X-EBAY-API-CERT-NAME' => 'yourcertname');
   $objHeader->push_header('X-EBAY-API-CALL-NAME' => 'GeteBayOfficialTime');
   $objHeader->push_header('X-EBAY-API-SITEID' => '0');
   $objHeader->push_header('Content-Type' => 'text/xml');
   
   # define the XML request
   my $request =
       "<?xml version='1.0' encoding='utf-8'?>" .
       "<GeteBayOfficialTimeRequest xmlns=\"urn:ebay:apis:eBLBaseComponents\">" .
       "  <RequesterCredentials>" .
       "    <eBayAuthToken>TOKENGoesHERE</eBayAuthToken>" .
       "  </RequesterCredentials>" .
       "</GeteBayOfficialTimeRequest>";
   
   # make the call
   my $objRequest = HTTP::Request->new(
     "POST",
     "https://api.sandbox.ebay.com/ws/api.dll",
     $objHeader,
     $request
   );
   
   # deal with the response
   my $objUserAgent = LWP::UserAgent->new;
   my $objResponse = $objUserAgent->request($objRequest);
   if (!$objResponse->is_error) {
     print $objResponse->content;
   }
   else {
     print $objResponse->error_as_HTML;
   }
*/


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 26th, 2009, 9:05 am 
Offline

Joined: December 7th, 2005, 8:29 am
Posts: 345
Hi,

How to disable cache in HTTPQuery?

I have created a little script that downloads a html page every 1 minute.

Code:
http://www.petitiononline.com/mod_perl/signed.cgi?dedis4mw


I wanted to use HTTPQuery in order to download the html into a var.

When using HTTPQuery the page that is saved is the same one all the time.... (caching?)

I used urldownloadtofile and it get me a new page every time.
I am don't want to use the urldownloadtofile command in order not to use a temp file.


Code:
#Persistent
#include %A_ScriptDir%\httpQuery.ahk

;Menu, Tray, NoStandard
Menu, Tray, add, Exit, Exit_Menu
Menu, Tray, Default , Exit
Menu, Tray, Tip, MW2 Petition Counter




First_Run=0
SetTimer, Get_Sig, 60000

Get_Sig:
html     := ""
URL:= "http://www.petitiononline.com/mod_perl/signed.cgi?dedis4mw"
length := httpQuery(html,URL)
varSetCapacity(html,-1)

Loop, Parse, html ,`n`r
{
  Current_Line_TXT=%A_LoopField%
  Current_Line_Number=%A_Index%
 
  Search_String=Total Signatures

  If Current_Line_TXT Contains %Search_String%
  {
    RegExMatch(Current_Line_TXT,".*6>(.*)\sT",R_Result)
    Result=%R_Result1%
   
    If(First_Run=0)
    {
      First_Run=1
      TrayTip, MW2 Petition Counter, %Result% Players signed!, 5,1
      Before=%Result%
    }
    Else
    {
      Diff:=(Result-Before)
      TrayTip, MW2 Petition Counter, %Result% Players signed!`nA minute ago we had %Before% signatures`nThats %Diff% More!, 5,1
      Before=%Result%
    }
    Return
  }
}
Return

Exit_Menu:
Msgbox, 36, MW2 Petition Counter, Are you sure you want to exit?
IfMsgBox, Yes
  Exitapp
Else
 Return


Help will be very appreciated

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  
 Post subject:
PostPosted: October 26th, 2009, 12:50 pm 
twhyman wrote:
How to disable cache in HTTPQuery?


comments from function source code wrote:
;Also if any special dwFlags are needed such as INTERNET_FLAG_NO_AUTO_REDIRECT or cache
; handling this might be set using the httpQueryDwFlags variable as global


Code:
...
Get_Sig:
html     := ""
URL:= "http://www.petitiononline.com/mod_perl/signed.cgi?dedis4mw"
httpQueryDwFlags = 0x80000000  ; INTERNET_FLAG_RELOAD = 0x80000000
length := httpQuery(html,URL)
varSetCapacity(html,-1)
...


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 26th, 2009, 3:53 pm 
Offline

Joined: December 7th, 2005, 8:29 am
Posts: 345
comment reader wrote:
twhyman wrote:
How to disable cache in HTTPQuery?


comments from function source code wrote:
;Also if any special dwFlags are needed such as INTERNET_FLAG_NO_AUTO_REDIRECT or cache
; handling this might be set using the httpQueryDwFlags variable as global


Code:
...
Get_Sig:
html     := ""
URL:= "http://www.petitiononline.com/mod_perl/signed.cgi?dedis4mw"
httpQueryDwFlags = 0x80000000  ; INTERNET_FLAG_RELOAD = 0x80000000
length := httpQuery(html,URL)
varSetCapacity(html,-1)
...


Thank you very much :D

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 5th, 2009, 10:56 pm 
Offline

Joined: February 17th, 2008, 5:01 pm
Posts: 303
Thank you, Der Raphael (and Heresey) for such a wonderful script.

In the function, the final receiver loop copies data using InternetReadFile in chunks of 1024 bytes. I noticed the following from the MSDN page on InternetReadFile: "WinINet attempts to write the HTML to the lpBuffer buffer a line at a time. If the application's buffer is too small to fit at least one line of generated HTML, the error code ERROR_INSUFFICIENT_BUFFER is returned as an indication to the application that it needs a larger buffer." Source:
http://msdn.microsoft.com/en-us/library ... 85%29.aspx

Is it possible that httpQuery might fail to download an entire file because the file contains a line longer than 1024 bytes long?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 11th, 2010, 5:17 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
For any interested parties, I've posted details of how to get this script working with AutoHotkey_L (Unicode or ANSI build).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2010, 6:53 pm 
Offline

Joined: February 20th, 2008, 5:08 pm
Posts: 111
Any ideas on how I can stop my app from crashing because of this error?
Image

_________________
My scripts: http://apps.nozavi.com


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 233 posts ]  Go to page Previous  1 ... 6, 7, 8, 9, 10, 11, 12 ... 16  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, JamixZol and 7 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