post json data ???

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
wzxiaodu
Posts: 12
Joined: 30 Nov 2013, 09:42

post json data ???

10 May 2019, 03:32

1111.PNG
1111.PNG (6.28 KiB) Viewed 1802 times
How to change to autohotkey ??

my results of the code below is empty !!!

2222.PNG
2222.PNG (2.87 KiB) Viewed 1802 times
pJson=
(
{
taskDateTime: 2019-01-05,
pCode: 330900
}
)

msgbox % JSONPOST(url,,pJson)
return

Code: Select all

;;;http thinkai.net /p/677   Thinkai's Blog
JSONPOST(url, Encoding = "",postData=""){ ;网址,编码, post JSON数据
    hObject:=ComObjCreate("WinHttp.WinHttpRequest.5.1")
    Try
    {
        hObject.Open("POST",url,False)
        hObject.SetRequestHeader("Content-Type", "application/json")
        hObject.Send(postData)
    }
    catch e
        return -1
 
    if (Encoding && hObject.ResponseBody)
    {
        oADO := ComObjCreate("adodb.stream")
        oADO.Type := 1
        oADO.Mode := 3
        oADO.Open()
        oADO.Write(hObject.ResponseBody)
        oADO.Position := 0
        oADO.Type := 2
        oADO.Charset := Encoding
        return oADO.ReadText(), oADO.Close()
    }
    return hObject.ResponseText
}

Last edited by wzxiaodu on 10 May 2019, 11:08, edited 1 time in total.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: ReyAHK and 222 guests