Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JoeGlines/349a3458b0ae307b4a5342a09555e23d to your computer and use it in GitHub Desktop.
Save JoeGlines/349a3458b0ae307b4a5342a09555e23d to your computer and use it in GitHub Desktop.
#SingleInstance,Force
IniRead, API_Key ,Auth.ini,API, Key ;Get your own key and put it into the API_Key variable
;**************************************
Term:="Pretty cool i think"
Endpoint:="https://capitalize-my-title.p.rapidapi.com/title/"
HTTP:=ComObjCreate("WinHttp.WinHttpRequest.5.1") ;Create COM Object
HTTP.Open("GET",Endpoint Term) ;Open the Connection
HTTP.SetRequestHeader("X-Rapidapi-Host","capitalize-my-title.p.rapidapi.com")
HTTP.SetRequestHeader("X-Rapidapi-Key",API_Key)
;~ HTTP.SetProxy(2,"localhost:8888") ;Use if Fiddler is running
HTTP.Send()
;~ clipboard:=HTTP.ResponseText ;Causes weird error
Msgbox % text:=ConvertResponseBody(HTTP)
ConvertResponseBody(oHTTP){
bytes:=oHTTP.Responsebody ;Responsebody has an array of bytes. Single characters.
loop, % oHTTP.GetResponseHeader("Content-Length") ;loop over responsbody 1 byte at a time
text .= chr( bytes[A_Index-1] ) ;lookup each byte and assign a charter
return text
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment