Jump to content

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


Recommended Posts

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

Link to post
Share on other sites

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 的白痴作者,不管是誰,去死一死好了

 

Link to post
Share on other sites

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

 

Link to post
Share on other sites
  • 2 months later...

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
Link to post
Share on other sites
  • 1 month later...
  • 1 month later...

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

Link to post
Share on other sites

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

Link to post
Share on other sites
  • 2 months later...
  • 2 months later...
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~~

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

Link to post
Share on other sites

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
Link to post
Share on other sites
  • 9 months later...

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.

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Mr_Microphone
      Alright, I may be an idiot.
      Three years ago, I wrote a program that pushed component information to a secure site via their API. I went back to add some attributes and (here's the idiot part) ended up losing the  source code and my modified code does not quite work. I have the compiled version that works minus the new attributes, so I know that their system has not changed. I stripped the larger program down from 3,000 lines to the part that is broken, but I am stumped. This was one of my first scripts, so it heavily leverages examples and isn't as pretty as I'd like it to be.
      Be gentle. 
      The program / script creates a new records as expected, but for some reason, I cannot access information in the response, which I need for a later step.
      I use Charles, a web debugging proxy tool so I can see the request and the response and both are as expected. Also, when I write to log file, the JSON reply is exactly what I expect and need, but when I try to do anything with the http body, it seems to be blank. 
      Here is the script minus  the URL and token:
      #include <Array.au3> #include <Curl.au3> #include <MsgBoxConstants.au3> #include <json.au3>  ; this was added as an alternate way to read the data Global $WM_serial_number = "WM20745001" Global $wm_component_status_id = "10" Global $wm_manufacturer ="Multi-Tech" Global $wm_model = "MTR-LAT1-B07" Global $cellular_carrier_id = "3" Global $iccid_esn = "89010303300012345678" Global $ip_address = "192.168.2.11" Global $NewIDNumber     Local $Curl = Curl_Easy_Init()     Local $Html = $Curl ; any number as identify     Local $Header = $Curl + 1 ; any number as identify     Local $HtmlFile = "cURL_Request.html"     Local $File = FileOpen($HtmlFile, 2 + 16)     Local $Slist = Curl_Slist_Append(0, "content-type: multipart/form-data; boundary=---011000010111000001101001")     $Slist = Curl_Slist_Append($Slist, "authorization: Token token=" & $Token)     Curl_Easy_Setopt($Curl, $CURLOPT_PROXY, "127.0.0.1") ; needed to use Charles web debugging proxy     Curl_Easy_Setopt($Curl, $CURLOPT_PROXYPORT, 8888) ; needed to use Charles     Curl_Easy_Setopt($Curl, $CURLOPT_HTTPHEADER, $Slist) ;     Curl_Easy_Setopt($Curl, $CURLOPT_URL, $Server & "wireless_module" & "s")     Curl_Easy_Setopt($Curl, $CURLOPT_SSL_VERIFYPEER, 0)     Curl_Easy_Setopt($Curl, $CURLOPT_TIMEOUT, 30)     Curl_Easy_Setopt($Curl, $CURLOPT_WRITEDATA, $Html)     Curl_Easy_Setopt($Curl, $CURLOPT_WRITEFUNCTION, Curl_FileWriteCallback())     Curl_Easy_Setopt($Curl, $CURLOPT_WRITEDATA, $File)     Local $HttpPost = ""     Local $LastItem = ""         Curl_FormAdd($HttpPost, $LastItem, $CURLFORM_COPYNAME, "wireless_module" & "[serial_number]", $CURLFORM_COPYCONTENTS, $WM_serial_number, $CURLFORM_END)         Curl_FormAdd($HttpPost, $LastItem, $CURLFORM_COPYNAME, "wireless_module" & "[component_status_id]", $CURLFORM_COPYCONTENTS, $wm_component_status_id, $CURLFORM_END)         Curl_FormAdd($HttpPost, $LastItem, $CURLFORM_COPYNAME, "wireless_module" & "[manufacturer]", $CURLFORM_COPYCONTENTS, $wm_manufacturer, $CURLFORM_END)         Curl_FormAdd($HttpPost, $LastItem, $CURLFORM_COPYNAME, "wireless_module" & "[model]", $CURLFORM_COPYCONTENTS, $wm_model, $CURLFORM_END)         Curl_FormAdd($HttpPost, $LastItem, $CURLFORM_COPYNAME, "wireless_module" & "[cellular_carrier_id]", $CURLFORM_COPYCONTENTS, $cellular_carrier_id, $CURLFORM_END)         Curl_FormAdd($HttpPost, $LastItem, $CURLFORM_COPYNAME, "wireless_module" & "[iccid_esn]", $CURLFORM_COPYCONTENTS, $iccid_esn, $CURLFORM_END)         Curl_FormAdd($HttpPost, $LastItem, $CURLFORM_COPYNAME, "wireless_module" & "[ip_address]", $CURLFORM_COPYCONTENTS, $ip_address, $CURLFORM_END)         ; submit         Curl_Easy_Setopt($Curl, $CURLOPT_HTTPPOST, $HttpPost)         Local $Code = Curl_Easy_Perform($Curl)         If $Code = $CURLE_OK Then         ConsoleWrite("Content Type: " & Curl_Easy_GetInfo($Curl, $CURLINFO_CONTENT_TYPE) & @LF)         ConsoleWrite("Download Size: " & Curl_Easy_GetInfo($Curl, $CURLINFO_SIZE_DOWNLOAD) & @LF)         MsgBox(0, 'Html', BinaryToString(Curl_Data_Get($Html))) ; this is something I threw in for debugging, expecting to see SOMETHING. Returns nothing         MsgBox(0, 'Header', BinaryToString(Curl_Data_Get($Header))) ; this is something I threw in for debugging, expecting to see SOMETHING. Returns nothing         Local $response = Curl_Easy_GetInfo($Curl, $CURLINFO_RESPONSE_CODE)             If $response = "409" Then $response = "Failed due to a conflict."             If $response = "200" Then $response = "Was NOT created."             If $response = "201" Then $response = "Was created."             ; read the ID that was assigned and store it         $NewIDNumber = StringRight(StringLeft(BinaryToString(Curl_Data_Get($Html)), 10), 4) ; this DID work, but now it doesn't. An old compiled version still works ;~         Global $JsonObject = json_decode($Html); another debugging attempt. Did not use json functions previously and the program worked without it. ;~         Global $NewIDNumber = json_get($JsonObject, '.id')         ConsoleWrite(@CRLF &'! id:' & $NewIDNumber & @CRLF & @CRLF)    ; debugging feedback         MsgBox(0, $response, $wm_serial_number & " new ID = " & $NewIDNumber); debugging feedback         If $Code <> $CURLE_OK Then ConsoleWrite(Curl_Easy_StrError($Code) & @LF)             Local $Data = BinaryToString(Curl_Data_Get($Curl))             Curl_Easy_Cleanup($Curl)             Curl_Data_Cleanup($Curl)             Curl_Data_Cleanup($Header)             Curl_Data_Cleanup($Html)             Curl_FormFree($HttpPost)             Curl_slist_free_all($Slist)             curl_easy_reset($Curl)             FileClose($File)             ConsoleWrite(@LF)         EndIf  This is the captured request (minus the host and token)
      POST /api/v2/wireless_modules HTTP/1.1 Host: api. Accept: */* authorization: Token token= Content-Length: 942 Expect: 100-continue content-type: multipart/form-data; boundary=---011000010111000001101001; boundary=------------------------9adb0d87c7ea5061 --------------------------9adb0d87c7ea5061 Content-Disposition: form-data; name="wireless_module[serial_number]" WM20745001 --------------------------9adb0d87c7ea5061 Content-Disposition: form-data; name="wireless_module[component_status_id]" 10 --------------------------9adb0d87c7ea5061 Content-Disposition: form-data; name="wireless_module[manufacturer]" Multi-Tech --------------------------9adb0d87c7ea5061 Content-Disposition: form-data; name="wireless_module[model]" MTR-LAT1-B07 --------------------------9adb0d87c7ea5061 Content-Disposition: form-data; name="wireless_module[cellular_carrier_id]" 3 --------------------------9adb0d87c7ea5061 Content-Disposition: form-data; name="wireless_module[iccid_esn]" 89010303300012345678 --------------------------9adb0d87c7ea5061 Content-Disposition: form-data; name="wireless_module[ip_address]" 192.168.2.11 --------------------------9adb0d87c7ea5061-- and the captured response
      HTTP/1.1 201 Created Date: Sun, 04 Apr 2021 00:12:18 GMT Server: Apache Cache-Control: max-age=0, private, must-revalidate Access-Control-Allow-Origin: not-allowed Vary: Accept-Encoding Access-Control-Max-Age: 1728000 X-XSS-Protection: 1; mode=block X-Request-Id: 71cfcf36-6020-48a6-a822-d2b393a27b69 Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: PUT, OPTIONS, GET, POST ETag: W/"25d97fe8a9387cb4b9029a9e62b0bfa2" X-Frame-Options: SAMEORIGIN, SAMEORIGIN X-Runtime: 0.344005 X-Content-Type-Options: nosniff Access-Control-Request-Method: * X-Powered-By: Phusion Passenger 5.2.1 Strict-Transport-Security: max-age=63072000; includeSubDomains; preload Location: /wireless_modules/3195 Status: 201 Created Connection: close Transfer-Encoding: chunked Content-Type: application/json; charset=utf-8 X-Charles-Received-Continue: HTTP/1.1 100 Continue {"id":3195,"model":"MTR-LAT1-B07","serial_number":"WM20745001","manufacturer":"Multi-Tech","mfg_date":null,"iccid_esn":"89010303300012345678","ip_address":"192.168.2.11","purchase_order":null,"supplier":null,"cellular_carrier_id":3,"component_status_id":10,"component_status":{"id":10,"name":"Hold","description":"Available- Held for specific use"},"custom_attributes":[{"name":"Deactivated","type":"Boolean","value":false},{"name":"Port 3001","type":"Boolean","value":false}],"comments":[]}  
      Also attached is the log file. I need to read the id value. Clearly, it is arriving back to cURL, since it is being written out to the log, but I cannot seem to get to it within the code. 
      It is established that I may be an idiot, but this idiot has wasted days in non-billable hours trying to figure out what should be a simple glitch.
      Help???
       
      cURL_Request.html
    • By genius257
      This is yet another HTTP server written in AutoIt3.
      Originally based on jvanegmond's POST HTTP Server.
      It is designed to be used either as is, or by scripts for a HTTP communication between any browser and AutoIt3.
      It can run PHP and AutoIt3 CGI, if setup in the settings ini file.
      Github repository
      AutoIt-HTTP-Server-master.zip
    • By tarretarretarre
      About AutoIt-API-WS
      AutoIt-API-WS is a light weight web server with expressive syntax, with the sole purpose of wrapping your existing AutoIt app with little to no effort.
      With AutoIt-API-WS you can send and receive data between any application or framework, as long they can handle HTTP requests, which is an industry standard today.
      Like my other communcations UDF AutoIt-Socket-IO AutoIt-API-WS is heavily inspired from the big boys, but this time its Laravel and Ruby on Rails.
      Features Highlights
      No external or internal dependencies required RESTful mindset when designed Expressive syntax Small codebase Heavy use of Michelsofts Dictionary object Limitations
      Not complient with any RFC, so something important could be missing. Time will tell! One persons slow loris attack will kill the process forever. Example of implemetnation (With screenshots)
      This is a basic cRud operation with the RESTful mindset in use.
      #include "API.au3" #include <Array.au3> _API_MGR_SetName("My APP DB adapter") _API_MGR_SetVer("1.0 BETA") _API_MGR_SetDescription("This adapter allows you to get this n that") _API_MGR_Init(3000) _API_MGR_ROUTER_GET('/users', CB_GetUsers, 'string sortBy', 'Get all users, sortBy can be either asc or desc. asc is default') _API_MGR_ROUTER_GET('/users/{id}', CB_GetUsersById, 'int id*', 'Get user by id') While _API_MGR_ROUTER_HANDLE() WEnd Func DB_GetUsers() Local $userA = ObjCreate("Scripting.Dictionary") Local $userB = ObjCreate("Scripting.Dictionary") $userA.add('id', 1) $userA.add('name', 'TarreTarreTarre') $userA.add('age', 27) $userB.add('id', 2) $userB.add('name', @UserName) $userB.add('age', 22) Local $aRet = [$userA, $userB] Return $aRet EndFunc Func CB_GetUsers(Const $oRequest) Local $aUsers = DB_GetUsers() If $oRequest.exists('sortBy') Then Switch $oRequest.item('sortBy') Case Default Case 'asc' Case 'desc' _ArrayReverse($aUsers) EndSwitch EndIf Return $aUsers EndFunc Func CB_GetUsersById(Const $oRequest) Local Const $aUsers = DB_GetUsers() Local $foundUser = Null For $i = 0 To UBound($aUsers) -1 Local $curUser = $aUsers[$i] If $curUser.item('id') == $oRequest.item('#id') Then $foundUser = $curUser ExitLoop EndIf Next If Not IsObj($foundUser) Then Return _API_RES_NotFound(StringFormat("Could not find user with ID %d", $oRequest.item('#id'))) EndIf return $foundUser EndFunc When you visit http://localhost:3000 you are greeted with this pleasent view that will show you all your registred routes and some extra info you have provided.

      When you visit http://localhost:3000/users the UDF will return the array of objects as Json
       
      And here is an example of http://localhost:3000/users/1

       
      More examples can be found here
       
       (NEWEST 2020-09-21)
      Autoit-API-WS-1.0.3-beta.zip
      OLD VERSIONS
      Autoit-API-WS-1.0.0-beta.zip Autoit-API-WS-1.0.1-beta.zip
       
    • By Jahar
      Hi,
      I am new to Autoit, Kindly guide me. I wanted to send a message with HTTP/GET to the URL https://ghsff.it/. How to do so?
    • By nacerbaaziz
      goodmorning autoit team
      today am comming with some winhttp problems, i hope that you can help me to solve them.
      the first problem
      is when opening a request
      my forums api allow me to delete any post using the api key
      all functions work, i mean post / get
      but when i tried to use the delete verb it's gave me an html 404 error
      here is what am tried
      #include "WinHttp.au3" ; Open needed handles Global $hOpen = _WinHttpOpen() Global $hConnect = _WinHttpConnect($hOpen, "xxxxxxxx.com") ; Specify the reguest: Global $hRequest = _WinHttpOpenRequest($hConnect, "Delete", "/vb/Api/posts/10447/?hard_delete=true", default, default) _WinHttpAddRequestHeaders($hRequest, "XF-Api-Key:xxxxx") _WinHttpAddRequestHeaders($hRequest, "XF-Api-User:xxxxx") ; Send request _WinHttpSendRequest($hRequest) ; Wait for the response _WinHttpReceiveResponse($hRequest) Global $sHeader = 0, $sReturned = 0 ; If there is data available... If _WinHttpQueryDataAvailable($hRequest) Then $sHeader = _WinHttpQueryHeaders($hRequest, $WINHTTP_QUERY_CONTENT_DISPOSITION) ;Or maybe: ; $sHeader = _WinHttpQueryHeaders($hRequest, BitOR($WINHTTP_QUERY_RAW_HEADERS_CRLF, $WINHTTP_QUERY_CUSTOM), "Content-Disposition") Do $sReturned &= _WinHttpReadData($hRequest) Until @error msgBox(64, "", $sReturned) endIf ; Close handles _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen)  
      and here is the error message
      <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>403 Forbidden</title> </head><body> <h1>Forbidden</h1> <p>You don't have permission to access /vb/Api/posts/10447/ on this server.<br /> </p> </body></html>  
      i hope you can help me 
      thanks in advance
×
×
  • Create New...