Jump to content
Ward

Curl UDF - AutoIt binary code version of libcurl with SSL support

Recommended Posts

trancexx

You have typo in __Curl_lstrlenW - wrong function called.

Excellent! Thanks for sharing.

  • Like 1

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
Ward

You found a bug in one second.... excellent!


新版 _ArrayAdd 的白痴作者,不管是誰,去死一死好了

 

Share this post


Link to post
Share on other sites
wakillon

When i try examples it return 

__MemoryModule_ModuleRecord and __MemoryModule_RuntimeLoader 

undefined function.

Edit : I have replaced #Include "BinaryCall.au3" by #Include <BinaryCall.au3> and it works !

Thanks

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
Ward

The last BinaryCall.au3 UDF can work with MemoryDll.au3. The related function will be called only if MemoryDll.au3 is included. It is checked inside BinaryCall.au3 by following line:

Static $HasMemoryDll = IsFunc(Execute('__MemoryModule_RuntimeLoader'))

For this Curl UDF. Both old and newer version of BinaryCall.au3 are worked.


新版 _ArrayAdd 的白痴作者,不管是誰,去死一死好了

 

Share this post


Link to post
Share on other sites
argumentum

to have no complain from ScITE, I changed those lines with Execute
 

If $HasMemoryDll Then
                Local $Module = Execute('__MemoryModule_ModuleRecord("get", Null, $DllName)')
                If $Module Then
                    Local $MemoryGetProcAddress = Execute('__MemoryModule_RuntimeLoader("MemoryGetProcAddress")')
                    If $MemoryGetProcAddress Then $Proc = DllCallAddress("ptr:cdecl", $MemoryGetProcAddress, "ptr", $Module, "str", $ProcName)[0]
                    If Not $Proc Then Return SetError(2, _BinaryCall_LastError("MemoryGetProcAddress failed on " & $ProcName), False)
                EndIf
            EndIf

 

Share this post


Link to post
Share on other sites
KotKot77

Can you give more details on how to use this awesome UDF to post a file, please.

I added the following two lines but it doesn't works (I'm sure that the POSTFIELDS part is wrong) :

Curl_Easy_Setopt($Curl, $CURLOPT_POST, 1)

Curl_Easy_Setopt($Curl, $CURLOPT_POSTFIELDS, "file=@C:\Users\KotKot\Desktop\logo.jpg")

Thanks for your help ...

Edited by KotKot77

Share this post


Link to post
Share on other sites
Mateusz

Can someone write example with PUT request with json content?

In linux I can send it via command:

curl -X PUT -H "Content-Type: application/json" -d'{"id":"1751","title":"some title","attr1":"value1","attr2":"value2"}' https://hostname/service --insecure

and it is working, but can't do the same on AutoIT.

Share this post


Link to post
Share on other sites
wakillon

Hi Ward

I'm a bit annoyed with the $CURLOPT_ACCEPT_ENCODING parameter.

Here is an example for get first bytes (for identify file/html instead of using "Content Type" who is not always reliable)

#Include 'Curl.au3'

Global $Curl, $iBufferSize, $Multi, $Running, $MsgsInQueue, $Code, $CURLMsg

$Curl = Curl_Easy_Init()
If Not $Curl Then Exit
$iBufferSize = 32
Curl_Easy_Setopt($Curl, $CURLOPT_URL, 'http://blogs.perl.org/users/kirk_kimmel/2012/08/q-when-not-to-use-regexp-a-html-parsing.html' )
Curl_Easy_Setopt ( $Curl, $CURLOPT_USERAGENT, 'AutoIt/Curl')
Curl_Easy_Setopt ( $Curl, $CURLOPT_FOLLOWLOCATION, 1 )
;~ An empty string creates an Accept-Encoding header containing all supported encodings.
Curl_Easy_Setopt ( $Curl, $CURLOPT_ACCEPT_ENCODING, '' ) ; Possible values : '', 'identity', 'deflate' or 'gzip'
Curl_Easy_Setopt ( $Curl, $CURLOPT_BUFFERSIZE, $iBufferSize )
Curl_Easy_Setopt ( $Curl, $CURLOPT_RANGE, '0-' & $iBufferSize -1 ) ; get the first n bytes. (Content-Range: bytes 0-31/nTotal )
Curl_Easy_Setopt ( $Curl, $CURLOPT_WRITEFUNCTION, Curl_DataWriteCallback() )
Curl_Easy_Setopt ( $Curl, $CURLOPT_WRITEDATA, $Curl)
Curl_Easy_Setopt ( $Curl, $CURLOPT_HEADERFUNCTION, Curl_DataWriteCallback() )
Curl_Easy_Setopt ( $Curl, $CURLOPT_HEADERDATA, $Curl + 1 )
$Multi = Curl_Multi_Init()
If Not $Multi Then Exit
Curl_Multi_Add_Handle ( $Multi, $Curl )

Do
    Curl_Multi_Perform ( $Multi, $Running )
    $CURLMsg = Curl_Multi_Info_Read ( $Multi, $MsgsInQueue )
    If DllStructGetData ( $CURLMsg, 'msg' ) = $CURLMSG_DONE Then
        $Curl = DllStructGetData ( $CURLMsg, 'easy_handle' )
        $Code = DllStructGetData ( $CURLMsg, 'data' )
        If $Code = $CURLE_OK Then
            ConsoleWrite ( 'Content Type: ' & Curl_Easy_GetInfo ( $Curl, $CURLINFO_CONTENT_TYPE ) & @CRLF )
            ConsoleWrite ( 'Download Size: ' & Curl_Easy_GetInfo ( $Curl, $CURLINFO_SIZE_DOWNLOAD ) & @CRLF )
            ConsoleWrite ( '- Header : ' & BinaryToString ( Curl_Data_Get ( $Curl + 1 ) ) & @Crlf )
            ConsoleWrite ( '+ Html String : ' & BinaryToString ( Curl_Data_Get ( $Curl ) ) & @Crlf )
            ConsoleWrite ( @CRLF )
            ConsoleWrite ( '> Html Binary : ' & Curl_Data_Get ( $Curl ) & @Crlf )
        Else
            ConsoleWrite ( '! Curl_Easy_StrError : ' & Curl_Easy_StrError ( $Code ) & @CRLF )
        EndIf
        Curl_Multi_Remove_Handle ( $Multi, $Curl )
        Curl_Easy_Cleanup ( $Curl )
        Curl_Data_Cleanup ( $Curl )
        Curl_Data_Cleanup ( $Curl + 1 )
    EndIf
    Sleep ( 10 )
Until $Running = 0
Curl_Multi_Cleanup ( $Multi )
Exit

Theoretically an empty string creates an Accept-Encoding header containing all supported encodings.

But in this case or if i use "gzip", script do not return any datas !

If i use "deflate" or "identity" or I do not use at all the "CURLOPT_ACCEPT_ENCODING" option, script return well datas as expected.

Is it a bug ?

Do you have a suggestion about that ?

 

Thanks.

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
wakillon

Well, I suppose that the problem is not from curl, but from the Buffer Size.

With a Buffer Size set to 128 instead of 32, script returns datas.

May be there is a minimal size to set to the buffer, but i do not find any infos on curl.haxx.se ...

 

Edit : May be a clue at line 189 on Curl.h 

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
fairylovehn127

where can i get this udf :(

Share this post


Link to post
Share on other sites
wakillon

where can i get this udf :(

here

Curl.7z


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
fairylovehn127

Do you have request.au3 example? I also need it

Share this post


Link to post
Share on other sites
wakillon

Do you have request.au3 example? I also need it

yes

 

Request UDF.7z


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
gcriaco

Any chance to support AutoIt X64?

 

Thanks and best regards

Peppe

Share this post


Link to post
Share on other sites
czyt
On 2015/6/4 at 7:29 PM, Ward said:

I built my own libcurl for AutoIt based on BinaryCall UDF.
libcurl - the multiprotocol file transfer library

The Features:

  • Pure AutoIt script, no DLLs needed.
  • Build with SSL/TLS and zlib support (without libidn, libiconv, libssh2).
  • Full easy-interface and partial multi-interface support.
  • Data can read from or write to autoit variables or files.
  • Smaller code size (compare to most libcurl DLL).

The version information of this build:

  • Curl Version: libcurl/7.42.1
  • SSL Version: mbedTLS/1.3.10
  • Libz Version: 1.2.8
  • Protocols: ftp,ftps,http,https

Here are the helper functions (not include in libcurl library). 

  • Curl_DataWriteCallback()
  • Curl_DataReadCallback()
  • Curl_FileWriteCallback()
  • Curl_FileReadCallback()
  • Curl_Data_Put()
  • Curl_Data_Get()
  • Curl_Data_Cleanup()

See the example script for detail usage.

Hidden Content

 

Curl.zip

支持啦,原来也是来自中国的兄弟啊~~

thx,Brother from China~~


董小姐,你微笑的时候很美,就像安河桥下,清澈的水...

Share this post


Link to post
Share on other sites
Iczer
Edited by Iczer
fail to post

Share this post


Link to post
Share on other sites
Iczer

I'm trying to make this UDF work under x64, but it seems just dll-repace not enough here

Maybe someone can correctly correct :) __Curl_RuntimeLoader() to work under x64

(for some reason it make post blank if i use any tags, so i uploaded my version of Curl UDF)

 

Curl - x64 & x86.au3

Edited by Iczer
fail to post

Share this post


Link to post
Share on other sites
Biatu

Can't seem to get this working...

Func Example_Post_1()
    Local $Curl = Curl_Easy_Init()
    If Not $Curl Then Return
    $bFile=FileRead("ReportData.7z")
    $tFile=DllStructCreate("byte["&BinaryLen($bFile)&"]")
    DllStructSetData($tFile,1,$bFile)
    $pFile=DllStructGetPtr($tFile)
    Local $HttpPost, $LastItem, $vHeader
    $vHeader=Curl_Slist_Append(0,"Content-Length: "&BinaryLen($bFile))
    Curl_Easy_Setopt($Curl, $CURLOPT_URL, "http://infinitycommunicationsgateway.net/Pub/CxbxBugs/test2.php")
    Curl_Easy_Setopt($Curl, $CURLOPT_USERAGENT, "AutoIt/Curl")
    Curl_Easy_Setopt($Curl, $CURLOPT_ACCEPT_ENCODING, "")
    Curl_Easy_Setopt($Curl, $CURLOPT_WRITEFUNCTION, Curl_DataWriteCallback())
    Curl_Easy_Setopt($Curl, $CURLOPT_WRITEDATA, $Curl)
    Curl_Easy_Setopt($Curl, $CURLOPT_VERBOSE,1)
    Curl_Easy_Setopt($Curl, $CURLOPT_POST, 1)
    Curl_Easy_Setopt($Curl, $CURLOPT_READFUNCTION, Curl_DataReadCallback())
    Curl_Easy_Setopt($Curl, $CURLOPT_READDATA, $bFile)
    Curl_Easy_Setopt($Curl, $CURLOPT_INFILESIZE_LARGE,BinaryLen($bFile))
    Curl_Easy_Setopt($Curl, $CURLOPT_FOLLOWLOCATION, 1)

    Local $Code = Curl_Easy_Perform($Curl)
    If $Code <> $CURLE_OK Then Return ConsoleWrite(Curl_Easy_StrError($Code) & @LF)
    Local $Data = BinaryToString(Curl_Data_Get($Curl))
    Local $EffectiveUrl = Curl_Easy_GetInfo($Curl, $CURLINFO_EFFECTIVE_URL)
    Curl_Easy_Cleanup($Curl)
    Curl_Data_Cleanup($Curl)

    ConsoleWrite("Paste link: " & $EffectiveUrl & @LF)
    Local $Match = $Data
    If @Error Then Return
    ConsoleWrite("RAW Paste Data: " & $Match & @LF)
    ConsoleWrite(@LF)
EndFunc

 


What is what? What is what.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • Melque_Lima
      By Melque_Lima
      A little help here please !?
      I'm trying to parse a file but the function is not working well! i think there is some thind doing wrong at FileRead()
      Obs: username,password and API link below is fictitious
      ConsoleWrite(">POST METHOD UPLOADING LOCAL IMAGE<" & @CRLF) _PostMethodTest() Func _PostMethodTest() Local Const $sAPIKey = '8f1e0a750088957' Local $sBoundary = "--------Boundary" Local $sHeaders = "Content-Type: multipart/form-data; boundary=" & $sBoundary & @CRLF Local $sData = '' Local $sFileName="image.jpg" Local $sFilePath="C:\Users\DELL\Desktop\" & $sFileName Local $hFile=FileOpen($sFilePath,16);16=$FO_BINARY Local $sFileData=FileRead($hFile) FileClose($hFile) $sData &= "--" & $sBoundary & @CRLF $sData &= 'Content-Disposition: form-data; name="myImage"; filename="' & $sFileName & '"' & @CRLF $sData &= 'Content-Type: application/upload' & @CRLF & @CRLF $sData &= BinaryToString($sFileData,0) & @CRLF $sData &= "--" & $sBoundary & @CRLF $sData &= 'Content-Disposition: form-data; name="username"' & @CRLF & @CRLF $sData &="myuserName" & @CRLF $sData &= "--" & $sBoundary & @CRLF $sData &= 'Content-Disposition: form-data; name="password"' & @CRLF & @CRLF $sData &="MyPassword" & @CRLF $sData &=$sBoundary & "--" ConsoleWrite($sData) Local $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("POST", "http://myapi", False) $oHTTP.SetRequestHeader("Content-Type", "multipart/form-data; " & "boundary=" & $sBoundary) $oHTTP.SetRequestHeader("apikey", $sAPIKey) $oHTTP.Send(StringToBinary($sData,1)) Local $sReceived = $oHTTP.ResponseText ConsoleWrite($sReceived & @CRLF) EndFunc ;==>_PostMethodTest  

    • Rex
      By Rex
      Some time ago I needed a way to uploade images to imgur, from one of my programs, and took a look at there API.
      Don't know if anyone can/would use it, but here is my code
       
      #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 ; #INDEX# ======================================================================================================================= ; Title .........: IMGUR Curl udf ; AutoIt Version : 1.0 ; Description ...: Uploads files to imgur using curl, and returns imgur url, deletion key, imgsize ect. in an array ; Author(s) .....: Rex ; =============================================================================================================================== #include-once #include <curl.au3> ; By Ward #include <JSON.au3> ; by Ward ; #FUNCTION# ==================================================================================================================== ; Name...........: _Imgur ; Description ...: Allows the user to uploade images to Imgur, or delete an already uploaded image using the images DeleteHash ; Syntax.........: _Imgur($AuthKey, True/False, $vData) ; Parameters ....: $AuthKey - API key from Imgur ; $bImg_Up - If true an image uploade is expected, if False a DeleteHas is expected ; $vData - The image to uploade, or the DeleteHash that was returned from Imgur at Image uploade ; Return values .: Success - An Array containing: ID, Datetime, type, animated, width, height, size, deletehash and url ; Failur - Sets @Error to 1 if no AuthKey is provided ; Failur - Sets @Error to 2 if $bImg_Up = True but no Image data is provided ; Failur - Sets @Error to 3 if $bImg_Up = True but $vData isn't Binary ; Failur - Sets @Error to 4 if $bImg_Up = False but no DeleteHash is provided ; Failur - Sets @Error to 5 if the API returns 400 -> Bad Request ; Failur - Sets @Error to 6 if the API returns 403 -> Permission Denied ; Failur - Sets @Error to 7 if the API returns 413 -> Data to large ; Failur - Sets @Error to 8 if the API returns 415 -> Unsupported data ; Failur - Sets @Error to 9 if Curl returns no Curl ; Failur - Sets @Error to 10 and returns Curl error msg if Curl fails ; Failur - Sets @Error to 11 If StringRegExp failed on the header (no array) ; Author ........: Rex ; Modified.......: ; Remarks .......: Needs Curl, Json And BinaryCall by Ward - Base64Encode By Ward and _EPOCH_Decrypt by Trancexx ; Is includede in the UDF is self ; Related .......: ; Link ..........: ; Example .......: $dFile = FileOpenDialog('Open', @ScriptDir, 'Image Files (*.jpg;*.jpeg;*.png;*.bmp;*.gif)', 1) ; Browse image ; $hData = FileOpen($dFile, 16) ; Open as binary ; $dData = FileRead($hData) ; Read the data ; FileClose($hData) ; Close the FileHandle ; $aData = _Imgur('APIKEY', True, $dData) ; Uploade the Image ; ; $aDelete = _Imgur('APIKEY', False, 'DELETEHASH') ; ; =============================================================================================================================== Func _Imgur($sAuthKey, $bImg_Up = True, $vData = '') ; Performe some error checking Select Case $sAuthKey = '' ; If no authkey is provided Return SetError(1, 0, -1) ; We set error to 1 Case $vData = '' And $bImg_Up = True ; If no image data is sendt Return SetError(2, 0, -1) ; We sent error to 2 Case $vData <> '' And $bImg_Up = True And IsBinary($vData) = 0 ; If $vData isn't binary Return SetError(3, 0, -1) ; We sent error to 3 Case $vData = '' And $bImg_Up = False ; If no deleta hash was send Return SetError(4, 0, -1) ; We sent error to 4 EndSelect Local $aResult[9] ; Return array Local $ProgressCallback = DllCallbackGetPtr(DllCallbackRegister("ShowProgress", "int:cdecl", "ptr;uint64;uint64;uint64;uint64")) Local $Curl = Curl_Easy_Init() If Not $Curl Then Return SetError(9, 0, -1) Local $sHtml = $Curl Local $sHeader = $Curl + 1 ; any number as identify Local $sList = Curl_Slist_Append(0, "User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:34.0) Gecko/20100101 Firefox/34.0") $sList = Curl_Slist_Append($sList, 'Referer: http://imgur.com/') $sList = Curl_Slist_Append($sList, 'Type: Base64') $sList = Curl_Slist_Append($sList, "Authorization: client-ID " & $sAuthKey) Curl_Easy_Setopt($Curl, $CURLOPT_HTTPHEADER, $sList) ; If $bImg_Up is true we uploads the image If $bImg_Up = True Then $dImage = _Base64Encode($vData) ; Convert the image to Base64 Curl_Easy_Setopt($Curl, $CURLOPT_URL, "https://api.imgur.com/3/upload/") ; If we wants to uploade an image Curl_Easy_Setopt($Curl, $CURLOPT_POST, 1) Curl_Easy_Setopt($Curl, $CURLOPT_COPYPOSTFIELDS, $dImage) Else ; If no img we expect a delete Curl_Easy_Setopt($Curl, $CURLOPT_URL, "https://api.imgur.com/3/image/" & $vData) ; If we wants to delete an image Curl_Easy_Setopt($Curl, $CURLOPT_CUSTOMREQUEST, 'DELETE') ; When we deletes an image EndIf ; Get header Curl_Easy_Setopt($Curl, $CURLOPT_HEADERFUNCTION, Curl_DataWriteCallback()) Curl_Easy_Setopt($Curl, $CURLOPT_HEADERDATA, $sHeader) Curl_Easy_Setopt($Curl, $CURLOPT_FOLLOWLOCATION, 1) ; Checks use this to see the respons from server, and get img url/delete hash ect. Curl_Easy_Setopt($Curl, $CURLOPT_WRITEFUNCTION, Curl_DataWriteCallback()) Curl_Easy_Setopt($Curl, $CURLOPT_WRITEDATA, $sHtml) Curl_Easy_Setopt($Curl, $CURLOPT_TIMEOUT, 30) Curl_Easy_Setopt($Curl, $CURLOPT_SSL_VERIFYPEER, 0) Curl_Easy_Setopt($Curl, $CURLOPT_NOPROGRESS, 0) Curl_Easy_Setopt($Curl, $CURLOPT_XFERINFOFUNCTION, $ProgressCallback) Local $Code = Curl_Easy_Perform($Curl) If $Code <> $CURLE_OK Then Return SetError(10, 0, Curl_Easy_StrError($Code)) EndIf ;ConsoleWrite(@CRLF & 'HEADER: ' & BinaryToString(Curl_Data_Get($sHeader)) & @CRLF) ;ConsoleWrite(@CRLF & 'HTML RAW: ' & BinaryToString(Curl_Data_Get($sHtml)) & @CRLF) ; Check what the header returns $aHeader = StringRegExp(BinaryToString(Curl_Data_Get($sHeader)), 'HTTP/1.1 (400|403|413|415|200)', 1) If IsArray($aHeader) Then Select Case $aHeader[0] = 400 ; If 403 then Permission Denied Return SetError(5, 0, -1) Case $aHeader[0] = 403 ; If 403 then Permission Denied Return SetError(6, 0, -1) Case $aHeader[0] = 413 ; If 413 then the data is to large Return SetError(7, 0, -1) Case $aHeader[0] = 415 ; If 415 then the data is unsupported Return SetError(8, 0, -1) Case $aHeader[0] = 200 ; If 200 uploade/delete was a sucess ; Decode the json returned from imgur Local $sJson = Json_Decode(BinaryToString(Curl_Data_Get($sHtml))) ; If deleting an image we only needs to return Sucess - IMGUR returns Sucess If $bImg_Up = False Then ReDim $aResult[1] ; Slim down the array $aResult[0] = 'Success' Return $aResult EndIf ; If an image was uploaded then we need to return some data to the user $aResult[0] = Json_Get($sJson, '["data"]["id"]') ; Imgur image id ; Date time the image was uploaded, it's returned in unix timestamp, so we converts it to regular time stamp $aResult[1] = _EPOCH_Decrypt(Json_Get($sJson, '["data"]["datetime"]')) ; Type of uploaded image $aResult[2] = Json_Get($sJson, '["data"]["type"]') ; Was the image animated $aResult[3] = Json_Get($sJson, '["data"]["animated"]') ; Width of the image $aResult[4] = Json_Get($sJson, '["data"]["width"]') ; Height of the image $aResult[5] = Json_Get($sJson, '["data"]["height"]') ; Size of the image $aResult[6] = Json_Get($sJson, '["data"]["size"]') ; Delete hash of the image $aResult[7] = Json_Get($sJson, '["data"]["deletehash"]') ; Image link $aResult[8] = Json_Get($sJson, '["data"]["link"]') Curl_Easy_Cleanup($Curl) Curl_Data_Cleanup($Curl) Curl_Slist_Free_All($sList) Return $aResult EndSelect Else ; If the Regexp failed Return SetError(11, 1, -1) EndIf EndFunc ;==>_Imgur Func ShowProgress($Ptr, $dltotal, $dlnow, $ultotal, $ulnow) ProgressSet(Int($ulnow / $ultotal * 100), '% Sendt = ' & Int($ulnow / $ultotal * 100)) Return 0 EndFunc ;==>ShowProgress ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name ..........: _EPOCH_Decrypt ; Description ...: Converts Epoch Time to human time ; Syntax ........: _EPOCH_Decrypt(TIMESTAMP) ; Return values .: Convertede timestamp ; Author ........: Trancexx ; Modified ......: ; Remarks .......: ; =============================================================================================================================== Func _EPOCH_Decrypt($iEpochTime) ; By trancexx forum thread: https://www.autoitscript.com/forum/topic/83667-epoch-time/ Local $iDayToAdd = Int($iEpochTime / 86400) Local $iTimeVal = Mod($iEpochTime, 86400) If $iTimeVal < 0 Then $iDayToAdd -= 1 $iTimeVal += 86400 EndIf Local $i_wFactor = Int((573371.75 + $iDayToAdd) / 36524.25) Local $i_xFactor = Int($i_wFactor / 4) Local $i_bFactor = 2442113 + $iDayToAdd + $i_wFactor - $i_xFactor Local $i_cFactor = Int(($i_bFactor - 122.1) / 365.25) Local $i_dFactor = Int(365.25 * $i_cFactor) Local $i_eFactor = Int(($i_bFactor - $i_dFactor) / 30.6001) Local $aDatePart[3] $aDatePart[2] = $i_bFactor - $i_dFactor - Int(30.6001 * $i_eFactor) $aDatePart[1] = $i_eFactor - 1 - 12 * ($i_eFactor - 2 > 11) $aDatePart[0] = $i_cFactor - 4716 + ($aDatePart[1] < 3) Local $aTimePart[3] $aTimePart[0] = Int($iTimeVal / 3600) $iTimeVal = Mod($iTimeVal, 3600) $aTimePart[1] = Int($iTimeVal / 60) $aTimePart[2] = Mod($iTimeVal, 60) Return StringFormat("%.2d/%.2d/%.2d %.2d:%.2d:%.2d", $aDatePart[0], $aDatePart[1], $aDatePart[2], $aTimePart[0], $aTimePart[1], $aTimePart[2]) EndFunc ;==>_EPOCH_Decrypt ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name ..........: _Base64Encode ; Description ...: Encodes data into Base64 ; Syntax ........: _Base64Encode(Data, Linebreak) ; Return values .: Base64 Encodede string ; Author ........: Ward ; Modified ......: ; Remarks .......: ; =============================================================================================================================== Func _Base64Encode($Data, $LineBreak = 76) ; By Ward Local $Opcode = '0x5589E5FF7514535657E8410000004142434445464748494A4B4C4D4E4F505152535455565758595A6162636465666768696A6B6C6D6E6F707172737' $Opcode &= '475767778797A303132333435363738392B2F005A8B5D088B7D108B4D0CE98F0000000FB633C1EE0201D68A06880731C083F901760C0FB6430125F0000000C1' $Opcode &= 'E8040FB63383E603C1E60409C601D68A0688470183F90176210FB6430225C0000000C1E8060FB6730183E60FC1E60209C601D68A06884702EB04C647023D83F' $Opcode &= '90276100FB6730283E63F01D68A06884703EB04C647033D8D5B038D7F0483E903836DFC04750C8B45148945FC66B80D0A66AB85C90F8F69FFFFFFC607005F5E' $Opcode &= '5BC9C21000' Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($Opcode) & "]") DllStructSetData($CodeBuffer, 1, $Opcode) $Data = Binary($Data) Local $Input = DllStructCreate("byte[" & BinaryLen($Data) & "]") DllStructSetData($Input, 1, $Data) $LineBreak = Floor($LineBreak / 4) * 4 Local $OputputSize = Ceiling(BinaryLen($Data) * 4 / 3) $OputputSize = $OputputSize + Ceiling($OputputSize / $LineBreak) * 2 + 4 Local $Ouput = DllStructCreate("char[" & $OputputSize & "]") DllCall("user32.dll", "none", "CallWindowProc", "ptr", DllStructGetPtr($CodeBuffer), _ "ptr", DllStructGetPtr($Input), _ "int", BinaryLen($Data), _ "ptr", DllStructGetPtr($Ouput), _ "uint", $LineBreak) Return DllStructGetData($Ouput, 1) EndFunc ;==>_Base64Encode I have added Wards curl, json and BinaryCall to the att. zip file.
       
      Cheers
      /Rex
      Includes.zip
    • Surya
      By Surya
      Hi everyone its been loooong since I posted here 
      I have been trying to convert this curl executable parameters into autoit using the winhttp com object;
      curl -F data_file=@my_audio_file.mp3 -F model=en-US "https://api.speechmatics.com/v1.0/user/41049/jobs/?auth_token=MmQ5MTk4jdsgjhgghstOGU5YS00OWFhLWghdgjshgdhbshj017###" any ideas guys
       
      PS: I am excited to post here after a looong time
    • Seminko
      By Seminko
      I'm trying to get data from http://poe.trade/ - disclaimer, although this site is about a game, my script will not in any way interact directly with the game in any way. The script is just to get data from the site.
      To explain how it works - you submit a POST request and a custom URL is returned, then you do a GET request on that URL and you get the final URL you want.
       
      First issue:
      Now, I've tried doing so by using https://apitester.com/ and the first phase works. Here's how it looks like at APITester:
      Request Headers POST /search HTTP/1.1 Host: poe.trade Accept: */* User-Agent: Rigor API Tester Content-Length: 43 Content-Type: application/x-www-form-urlencoded Request Body online=x&name=kaom%27s%20heart&league=incursion When I submit this, the response I get is this:
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <title>Redirecting...</title> <h1>Redirecting...</h1> <p>You should be redirected automatically to target URL: <a href="http://poe.trade/search/ioritewoteteme">http://poe.trade/search/ioritewoteteme</a>. If not click the link. So I then do a GET request for 'http://poe.trade/search/ioritewoteteme', which results in this response:
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <title>Redirecting...</title> <h1>Redirecting...</h1> <p>You should be redirected automatically to target URL: <a href="http://poe.trade/search/inamotezuakito">http://poe.trade/search/inamotezuakito</a>. If not click the link. Great, this link (http://poe.trade/search/inamotezuakito) is exactly what we want.
      However, when I try to do the same in autoit, the result is quite different:
      Global Const $HTTP_STATUS_OK = 200 $test = HttpPost("http://poe.trade/search", "/online=x&name=kaom%27s%20heart&league=incursion") ClipPut($test) MsgBox(1, "", $test) Func HttpPost($sURL, $sData = "") Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHTTP.Open("POST", $sURL, False) If (@error) Then Return SetError(1, 0, 0) $oHTTP.SetRequestHeader("Host", "poe.trade") $oHTTP.SetRequestHeader("User-Agent", "Rigor API Tester") $oHTTP.SetRequestHeader("Accept", "*/*") $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") $oHTTP.Send($sData) If (@error) Then Return SetError(2, 0, 0) If ($oHTTP.Status <> $HTTP_STATUS_OK) Then Return SetError(3, 0, 0) Return SetError(0, 0, $oHTTP.ResponseText) EndFunc The code above returns: ' 謟 '
      Any ideas as to what I am doing incorrectly?
       
      Second issue:
      Once I get the final link using APITester and do a GET on that i get a bunch of hieroglyphs. A friend of mine advised that the data is GZiped, which is a pain in the butt to be honest. However, apparently curl can uncompres that.
      How would I go about it?
       
      Thanks
×