Jump to content

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

[Func] HTTPRequest: for Web APIs [AHK-B + AHK-L+Unicode+x64]


  • Please log in to reply
380 replies to this topic
hunts02
  • Members
  • 5 posts
  • Last active: Sep 03 2013 12:27 AM
  • Joined: 20 Aug 2013

Hello,

 

Sorry but a little bit offtopic, Can you help me convert this code to yours?

 

#include httpQuery.ahk

username = usertest

password = testing

URL := username ":" password "@twitter.com/statuses/update.xml?"

status:="Hello World"

POSTdata := "status="status

httpQUERY(buffer:="",URL,POSTdata)

msgbox %buffer%

Return

 

Found this on forums. It is updating status on twitter. But I can't get it to work on autohotkey_l. Any help is appreciated.



tmplinshi
  • Members
  • 245 posts
  • Last active: Mar 12 2015 02:29 PM
  • Joined: 06 Apr 2012

Hello,
 
Sorry but a little bit offtopic, Can you help me convert this code to yours?
 
#include httpQuery.ahk
username = usertest
password = testing
URL := username ":" password "@twitter.com/statuses/update.xml?"
status:="Hello World"
POSTdata := "status="status
httpQUERY(buffer:="",URL,POSTdata)
msgbox %buffer%
Return
 
Found this on forums. It is updating status on twitter. But I can't get it to work on autohotkey_l. Any help is appreciated.

#Include HTTPRequest.ahk

username := "usertest"
password := "testing"
URL      :=  username ":" password "@twitter.com/statuses/update.xml?"

status   := "Hello World"
POSTdata := "status=" status

HTTPRequest(URL, InOutData := POSTdata)
MsgBox, %InOutData%

; If you are using Unicode AHK, you might need specify "Charset=utf-8" option.
HTTPRequest(URL, InOutData := POSTdata,, "Charset=utf-8")
MsgBox, %InOutData%

Return


hunts02
  • Members
  • 5 posts
  • Last active: Sep 03 2013 12:27 AM
  • Joined: 20 Aug 2013

Hello tmplinshi,

 

Thank you for the reply. I have the Unicode one but it seems it does authenticate but not post anything on the page and it outputs the message box as status=Hello World.



VxE
  • Moderators
  • 3622 posts
  • Last active: Dec 24 2015 02:21 AM
  • Joined: 07 Oct 2006
When HTTPRequest encounters a problem that prevents it from completing the request, it usually dumps a summary into the variable supplied as the third parameter (IN_OUT_HEADERS). It provides a good starting point for debugging your queries.

Also, twitter deprecated that authentication scheme ages ago, so you will never be able to tweet anything that way, but you should at least see a '4xx' response from twitter.

djvj
  • Members
  • 70 posts
  • Last active: Jul 22 2016 02:54 AM
  • Joined: 19 Sep 2010

I was testing your imgur script example and after entering the HTTPRequest function, something is crashing the script and when hovering my mouse over the H icon in my running tasks, it vanishes. Does the example script still work? I'm on win8-64 and using ahk_H ansi. Thanks.



VxE
  • Moderators
  • 3622 posts
  • Last active: Dec 24 2015 02:21 AM
  • Joined: 07 Oct 2006
HTTPRequest was not made to be compatible with AHK-H.

smorgasboard
  • Members
  • 660 posts
  • Last active: Jan 14 2016 08:53 AM
  • Joined: 18 Jul 2012

http://auto-hotkey.com/

 

in case something goes kaput kindly join the above

 

for instant help/chat join #ahk-social OR #ahk at IRC



Stas
  • Members
  • 1 posts
  • Last active: Feb 26 2014 10:06 PM
  • Joined: 16 Jan 2014

Hi VxE,

 

Your script works great for me under Windows XP, but the AutoProxy function stopped working when I migrated my script to Windows 7. My proxy (which requires authentication) throws the following error:

Error Code: 407 Proxy Authentication Required. The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. (12209)

I tried to find a way to configure the proxy manually, but only found a way to set the proxy URL (but not the username and password).

 

Do you have any ideas?



lingoist
  • Members
  • 122 posts
  • Last active: Jan 28 2014 03:50 PM
  • Joined: 05 Oct 2004

It's a common source of confusion, but the charset option only effects POST data, that is, data you want to upload.

Also, it appears that tingchina.com does not specify a character set in its response headers, so HTTPRequest assumes the page text is your current windows ANSI codepage. Override this uncertainty using either the Binary or Expect:utf-8 option.

 

Dear VeX,

 

I have been working on this for some days, but I haven't succeeded... The variable with website code shows unexpected characters, like "�".

 

Response headers says that charset is iso-8859-1 (Latin1):

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

 

Then, I tried to use the following code, but still not working.

HTTPRequest(url, POSTData, Headers, "Charset=UTF-8`n+Flag: INTERNET_FLAG_NO_COOKIES`nExpect:iso-8859-1" )

 

Would you have some idea what's happening?

 

Thanks a lot!

lingoist



akman
  • Members
  • 3 posts
  • Last active: Sep 19 2014 12:52 PM
  • Joined: 13 Feb 2014

Hi! Maby sombody help me, I can't recieve

 

When I do this script

URL := "%googlesite%"
headers := "Content-Type: audio/x-flac; rate=16000"

file := "c:\voice.flac"

HTTPRequest(URL, file, headers)
msgbox, % file
Return

#include httprequest.ahk

I receive blanc MsgBox

Where is my mistake?



Wicked
  • Members
  • 504 posts
  • Last active: Nov 18 2018 02:17 AM
  • Joined: 07 Jun 2008
IDK which headers you need, or for which API, but URL:=googlesite or URL=%googlesite%.

3nL8f.png


Scorpix
  • Members
  • 8 posts
  • Last active: Apr 13 2014 07:30 AM
  • Joined: 09 Mar 2014

Hi, 

 

I have a problem with greek letters and HTTPRequest.

 

 

With polish letters i was using it like 

First step:

HTTPRequest( URL POST, Guild_name := "")

And getting for example Guild_name = Dzieci Słońca

 

Then i was using 

Second step:

Guild_name_UTF8 := Ansi2UTF8(Guild_name)
Ansi2UTF8(sString)
{
	Ansi2Unicode(sString, wString, 0)
	Unicode2Ansi(wString, zString, 65001)
	Return zString
}

Ansi2Unicode(ByRef sString, ByRef wString, CP = 0)
{
 nSize := DllCall("MultiByteToWideChar"
, "Uint", CP
, "Uint", 0
, "Uint", &sString
, "int",  -1
, "Uint", 0
, "int",  0)


VarSetCapacity(wString, nSize * 2)


DllCall("MultiByteToWideChar"
, "Uint", CP
, "Uint", 0
, "Uint", &sString
, "int",  -1
, "Uint", &wString
, "int",  nSize)
}


Unicode2Ansi(ByRef wString, ByRef sString, CP = 0)
{
 nSize := DllCall("WideCharToMultiByte"
, "Uint", CP
, "Uint", 0
, "Uint", &wString
, "int",  -1
, "Uint", 0
, "int",  0
, "Uint", 0
, "Uint", 0)


VarSetCapacity(sString, nSize)


DllCall("WideCharToMultiByte"
, "Uint", CP
, "Uint", 0
, "Uint", &wString
, "int",  -1
, "str",  sString
, "int",  nSize
, "Uint", 0
, "Uint", 0)
}
 

which gives  Guild_name_UTF8 = Dzieci SĹ‚oĹ„ca

 
Third step:

and at last i put Guild_name_UTF8 to MySql database and somehow it works on my website showing "Dzieci Słońca" :)

 

Same procedure works with other special characters and other languages. But fails at Step 1 with greek language.

 

With greek after step 1 i get Guild_name = ?????? which should be  Τ Α Λ Ω Σ

 

 

I've tried to use option "binary" but it did't worked well.

 

Binary 1 step:

HTTPRequest( URL POST, Guild_name := "", , "binary")

Guild_name = ΤΑΛΩΣ

 

Binary 2 Second step:

Guild_name_UTF8 := Ansi2UTF8(Guild_name)

Guild_name_UTF8 = ΤÎâ€ĂŽâ€şĂŽÂ©ĂŽĹ

 
 
Third step:

After putting to database, it shows "ΤΑΛΩΣ" on website :(

 

I'm sure you guys can help me not only with greek letters but also mayby to do it some other/easier way because i know i'm doing it in kinda roud way.

 

Autohotkey v1.1.14.03 ANSI

Notepad ++ Encoding ANSI



Bartimus
  • Members
  • 237 posts
  • Last active: Nov 10 2016 05:01 PM
  • Joined: 10 Nov 2005

Links in the first post broken.



britrocker
  • Members
  • 4 posts
  • Last active: Feb 22 2015 06:04 PM
  • Joined: 05 May 2014

good jobs thx too

 

......................

 

เกมกีฬาการพนัน



mindmadness
  • Members
  • 1 posts
  • Last active: Jul 07 2019 02:27 PM
  • Joined: 07 Jun 2014

Links in the first post broken.

 

I have hosted version 2.49 of the httpRequest.ahk file on my personal dropbox until such time as VxE updates their links.
https://dl.dropboxus...httpRequest.ahk