Moxom160

Problem with SOAP with Attachment

15 posts in this topic

#1 ·  Posted (edited)

Hello

First i want to say that most of my problems i can solve while scripting by looking at the forum or in the help file but im stuck on this specific problem. I have been writing scripts to consume Web services and this works fine when its just plain XML responses. I work on a project now where i need to consume a SOAP response with an Attachment. I can make the plain SOAP call and get a response as well but i dont know how to handle the multipart and binary data. I have tried ADODB.Stream to write the data to a file but this just writes everything. I would be very grateful if someone could point me into the right direction.

Please find below the Request and the Response i get at the momen

 

$objHTTP = ObjCreate("Microsoft.XMLHTTP")
$objReturn = ObjCreate("Msxml2.DOMDocument.3.0")
$oDATA=ObjCreate("ADODB.Stream")

$strEnvelope = '<?xml version="1.0" encoding="UTF-8"?>' _
'<soapenv:Envelope' _
'xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"' _
'xmlns:xsd="http://www.w3.org/2001/XMLSchema"' _
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' _
'<soapenv:Body>' _
'<ns1:getStorageAccessTicket' _
'soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"' _
'xmlns:ns1="NBRStorageService">' _
'<siteId xsi:type="xsd:long">123456</siteId>' _
'<username xsi:type="xsd:string">USERNAME</username>' _
'<password xsi:type="xsd:string">PASSWORD</password>' _
'</ns1:getStorageAccessTicket>' _
'</soapenv:Body>'
'</soapenv:Envelope>' _

; Set up to post to the server
$objHTTP.open ("post", "API end point" , False)

; Set a standard SOAP/ XML header for the content-type
$objHTTP.setRequestHeader ("Content-Type", "application/xml")

; Set a header for the method to be called
$objHTTP.setRequestHeader ("SOAPAction", 'getStorageAccessTicket')

ConsoleWrite("Content of the Soap envelope :" & @CR & $strEnvelope & @CR & @CR )

; Make the SOAP call
$objHTTP.send ($strEnvelope)

; Get the return envelope
$strReturn = $objHTTP.responsetext

With $oDATA
        .Type=1
        .Open
        .Write($objHTTP.ResponseBody)
        .SaveToFile(@ScriptDir&'\captcha.arf', 2)
        .Close
    EndWith
EndFunc

RESPONSE:
'------=_Part_5_987625235.1444159091234'
'Content-Type: text/xml; charset=UTF-8'
'Content-Transfer-Encoding: binary'
'Content-Id: <DF72463F6FAFE80B930059E761DF7225>'

'<?xml version="1.0" encoding="UTF-8"?>'
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'
 '<soapenv:Body>'
  '<ns1:downloadNBRStorageFileResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="NBRStorageService">'
   '<ns1:downloadNBRStorageFileReturn xsi:type="soapenc:Array" soapenc:arrayType="ns1:DataHandler[2]" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">'
    '<item href="cid:FE782065C11E6558C9C8925EBE3D687F"/>'
    '<item href="cid:3CF0B37E4C5932A3E60EBA5226CFC30A"/>'
   '</ns1:downloadNBRStorageFileReturn>'
  '</ns1:downloadNBRStorageFileResponse>'
 '</soapenv:Body>'
'</soapenv:Envelope>'
------=_Part_5_987625235.1444159091234
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
Content-Id: <FE782065C11E6558C9C8925EBE3D687F>

Attachment.arf
2342371
false
------=_Part_5_987625235.1444159091234
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
Content-Id: <3CF0B37E4C5932A3E60EBA5226CFC30A>

 

Edited by Moxom160
correction

Share this post


Link to post
Share on other sites



Moxom160,

.SaveToFile(@ScriptDir&'\captcha.arf', 2)

As the Forum rules are clear on the fact that we do not support anything that deals with CAPTCHAs, could you please explain what this line is doing.

M23

 


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Hello Melba

I think there is missunderstanding. I was trying around different bits of code and found one snipped where the file name was set to captcha.png. since i was only testing i did not change the file name to something else. Im not planning on dealing with CAPTCHAs or anything like this.

To prove my indention please find below a link to the service im trying to access. Im trying to retrieve webex recordings via the NBR(network based recording) API.

https://developer.cisco.com/site/webex-developer/develop-test/nbr-web-services-api/api-functions.gsp#downloadNBRStorageFile

Sorry for the missunderstanding.

regards

Share this post


Link to post
Share on other sites

Moxom160,

Fine - but please be careful which "snippets" you use in future.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

You need to parse returned data to extract the attachment. It shouldn't be hard since it's standard MIME.

Can you post the exact response? Parts are missing from your post.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Hello trancexx

The response i posted above is every thing i get in human readable form .after the last ------=_Part_5_987625235.1444159091234 and the content ids it streams down binary data.

I have tested today to stream the reponse via ADODB.Stream to a local file and this works fine. The only think im stuck at on how to seperate the binary data from the top 30 lines of response. Im only interested in the binary which i require to generate the recording file.

I have attached a response so you can have look at it. Thank you already for looking at this.

test.xml

Share this post


Link to post
Share on other sites

That file misses the most important data to process it correctly - the original MIME header. 


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Does this help further? I have this from the API doc from Cisco.

Soap Response:

  HTTP/1.1 200 OK
  Date: Wed, 28 Apr 2010 10:36:46 GMT
  Content-Type: multipart/related; type="text/xml";
  start="<92AE6C82DBBD12B997D03C502A058511>
    "; boundary="----=_Part_0_23877553.1272451006846"
    Connection: Close
    ------=_Part_0_23877553.1272451006846
    Content-Type: text/xml; charset=UTF-8
    Content-Transfer-Encoding: binary
    Content-Id: <92AE6C82DBBD12B997D03C502A058511>
  <?xml version="1.0" encoding="utf-8"?>
  <soapenv:Envelope
  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
      <ns1:downloadNBRStorageFileResponse
  soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:ns1="NBRStorageService">
        <downloadNBRStorageFileReturn
  soapenc:arrayType="ns1:DataHandler[2]" xsi:type="soapenc:Array"
  xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
          <downloadNBRStorageFileReturn
  href="cid:B0A8EBE4A6E3C12D01C9AA96201968E5"
  xsi:type="ns1:DataHandler"/>
            <downloadNBRStorageFileReturn
  href="cid:6E5E9F315D7E46BF51A3729E71BD10D3"
  xsi:type="ns1:DataHandler"/>
          </downloadNBRStorageFileReturn>
        </ns1:downloadNBRStorageFileResponse>
      </soapenv:Body>
    </soapenv:Envelope>
  ------=_Part_0_23877553.1272451006846
  Content-Type: application/octet-stream
  Content-Transfer-Encoding: binary
  Content-Id: <B0A8EBE4A6E3C12D01C9AA96201968E5>
    a.arf
    188607
    ------=_Part_0_23877553.1272451006846
    Content-Type: application/octet-stream
    Content-Transfer-Encoding: binary
    Content-Id: <6E5E9F315D7E46BF51A3729E71BD10D3>
  .............
    

Share this post


Link to post
Share on other sites

Does this work?

$sFile = "test.xml"
$sCID = "16F8B262D5B9C561D8899E638D3B3D8C"
$sOutFile = "YourAttachment.txt"

GetCIDAttachment($sFile, $sCID, $sOutFile)

If @error Then
    $sErrDesc = "You can't use this method because "
    Switch @error
        Case 1
            $sErrDesc &= "it sucks for you."
        Case 2
            $sErrDesc &= "getting stream failed."
        Case 3
            $sErrDesc &= "loading EML failed."
        Case 4
            $sErrDesc = "Saving to file failed."
        Case 5
            $sErrDesc = "No such attachment exists."
    EndSwitch
    MsgBox(4096, "Error", $sErrDesc & @CRLF)
Else
    MsgBox(4096, "Yay!", "Attachment with Content-Id <" & $sCID & '> extracted to "' & $sOutFile & '"' & @CRLF)
EndIf





Func GetCIDAttachment($sPath, $sCID, $sOutFile = Null)
    Local $oErrHandler = ObjEvent("AutoIt.Error", GetAttachmentSize) ; Red Jon fucked up COM

    Local $oMessage = ObjCreate("{CD000001-8B95-11D1-82DB-00C04FB1625D}")
    If @error Then Return SetError(1, 0, 0)

    Local $oMessageStream = $oMessage.GetStream()
    If @error Then Return SetError(2, 0, 0)

    $oMessageStream.LoadFromFile($sPath)
    If @error Then Return SetError(3, 0, 0)

    $oMessageStream.Flush() ; this is essential

    For $oBodyPart In $oMessage.BodyPart.BodyParts
        For $oField In $oBodyPart.Fields
            If $oField.Name = "urn:schemas:mailheader:content-id" And $oField.Value = "<" & $sCID & ">" Then
                If $sOutFile Then Return $oBodyPart.GetDecodedContentStream().SaveToFile($sOutFile, 2) ; adSaveCreateOverWrite
                If @error Then Return SetError(4, 0, 0)
                Return $oBodyPart.GetDecodedContentStream().Read()
            EndIf
        Next
    Next

    Return SetError(5, 0, 0)
EndFunc

It should extract "attachment" with Content-Id <16F8B262D5B9C561D8899E638D3B3D8C> from "test.xml" to file named "YourAttachment.txt". All located in the script's folder.

1 person likes this

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Hello trancexx

thanks for the script but running the above on my XML gives me "no such attachment exists".  I have tried different Content-ID's to see if i get different result but its always the same error.

 

 

Edited by Moxom160

Share this post


Link to post
Share on other sites

Hello trancexx

thanks for the script but running the above on my XML gives me "no such attachment exists".  I have tried different Content-ID's to see if i get different result but its always the same error.

 

 

I told you that the file you posted here isn't full. It's missing header part where boundary is defined.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Something like this:

Content-Type: Multipart/Related; boundary=----=_Part_39_1838099744.1444244895679; type=text/xml;

 


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

My guess is that you're missing headers. For your original code it could be:

With $oDATA
    .Type = 2
    .Open()
    .WriteText($objHTTP.getAllResponseHeaders() & $objHTTP.ResponseText)
    .SaveToFile(@ScriptDir & '\captcha.arf', 2)
    .Close()
EndWith

 


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Hello trancexx

I have just tried you suggestions and you were absolutly right i need to get the full headers and formating corrected. Its working now perfectly. thank you for the support.

Have day.

mox

Share this post


Link to post
Share on other sites

@trancexx

As always, again I learned something interesting, as I wast thought that IMessage is only for EML , now I re read MSDN doc for this.
Thanks
 

mLipok


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

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

    • mLipok
      By mLipok
      Recently I was working on TeamVierwer API .
      I had a little break, and wanted to check out another platform.
      Here is the result of my attempt:
      #include "GHAPI.au3" _GHAPI_AccessToken('b3e8.....de..........bdc3a0c.....bd27c6f') _GHAPI_GetUser("users/mLipok") _GHAPI_GetUserOrganizations("users/mLipok") _GHAPI_RootEndpoints() and GHAPI.au3
      #include-once #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 #Tidy_Parameters=/sort_funcs /reel #Region GHAPI.au3 - Header ; #INDEX# ======================================================================================================================= ; Title .........: GHAPI UDF ; AutoIt Version : 3.3.10.2++ ; Language ......: English ; Description ...: This is an UDF for for communicate with https://api.github.com via GitHub RESTful API ; Author(s) .....: mLipok ; Modified ......: ; =============================================================================================================================== #cs Title: GHAPI UDF Filename: GHAPI.au3 Description: This is an UDF for for communicate with https://api.github.com via GitHub RESTful API Author: mLipok Modified: Last Update: 2017/05/23 Requirements: AutoIt 3.3.10.2 or higher #ce #EndRegion GHAPI.au3 - Header #Region GHAPI.au3 - Include #include <array.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #EndRegion GHAPI.au3 - Include #Region GHAPI.au3 - Declarations Global $oErrorHandler = ObjEvent("AutoIt.Error", "_GHAPI_ErrFunc") Global $__g_sGitHubAPI_BaseUrl = "https://api.github.com" ; URL of the GitHub API Global $__g_sGitHubAPI_Version = "v3" ; Put the current API version in here Global Enum _ $GHAPI_ERR_SUCCESS, _ $GHAPI_ERR_GENERAL, _ $GHAPI_ERR_COMERROR, _ $GHAPI_ERR_STATUS, _ $GHAPI_ERR_COUNTER Global Enum _ $GHAPI_EXT_DEFAULT, _ $GHAPI_EXT_PARAM1, _ $GHAPI_EXT_PARAM2, _ $GHAPI_EXT_PARAM3, _ $GHAPI_EXT_COUNTER Global Enum _ $GHAPI_RET_SUCCESS, _ $GHAPI_RET_FAILURE, _ $GHAPI_RET_COUNTER #EndRegion GHAPI.au3 - Declarations #Region GHAPI.au3 - API Functions Func _GHAPI_ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_GHAPI_ErrFunc Func _GHAPI_AccessToken($sParam = Default) ; https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/ ; https://github.com/settings/tokens Local Static $sAccessToken = '' If $sParam <> Default Then $sAccessToken = $sParam Return $sAccessToken EndFunc ;==>_GHAPI_AccessToken Func _GHAPI_GetUser($sUser) Local $oHTTP = __GHAPI_HTTP_Open("GET", $sUser) Local $oJSON = __GHAPI_HTTP_Send($oHTTP) If @error Then Return SetError(@error, @extended, False) #forceref $oJSON EndFunc ;==>_GHAPI_GetUser Func _GHAPI_GetUserOrganizations($sUser) Local $oHTTP = __GHAPI_HTTP_Open("GET", $sUser & '/orgs') Local $oJSON = __GHAPI_HTTP_Send($oHTTP) If @error Then Return SetError(@error, @extended, False) #forceref $oJSON EndFunc ;==>_GHAPI_GetUserOrganizations Func _GHAPI_RootEndpoints() Local $oHTTP = __GHAPI_HTTP_Open("GET", '') Local $oJSON = __GHAPI_HTTP_Send($oHTTP) If @error Then Return SetError(@error, @extended, False) #forceref $oJSON EndFunc ;==>_GHAPI_RootEndpoints #EndRegion GHAPI.au3 - API Functions #Region GHAPI.au3 - INTERNAL Functions Func __GHAPI_HTTP_Open($sMethod, $sCommand, $sURLParameters = '') Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") Local $sURL = $__g_sGitHubAPI_BaseUrl & "/" & $sCommand & $sURLParameters ;~ __GHAPI_DebugOut("> $sURL=" & $sURL & @CRLF) $oHTTP.Open($sMethod, $sURL, False) If @error Then Return SetError(@error, @extended, Null) $oHTTP.setRequestHeader("Authorization", "Bearer " & _GHAPI_AccessToken()) ; Accept: application/vnd.github.v3+json $oHTTP.setRequestHeader("Accept", "application/vnd.github." & $__g_sGitHubAPI_Version & "+json") ; User-Agent: Awesome-Octocat-App $oHTTP.setRequestHeader("User-Agent", "AutoIt UDF") Return $oHTTP EndFunc ;==>__GHAPI_HTTP_Open Func __GHAPI_HTTP_Send(ByRef $oHTTP, $sSendParameter = Default) If $sSendParameter = Default Then $oHTTP.Send() Else $oHTTP.Send($sSendParameter) EndIf ConsoleWrite('+' & $oHTTP.Status & @CRLF) ConsoleWrite('>' & $oHTTP.StatusText & @CRLF) ConsoleWrite($oHTTP.ResponseText & @CRLF) ConsoleWrite(@CRLF) If @error Then Return SetError(@error, @extended, $GHAPI_RET_FAILURE) ;~ Return SetError($GHAPI_ERR_SUCCESS, $oJSON.Size, $oJSON) EndFunc ;==>__GHAPI_HTTP_Send #EndRegion GHAPI.au3 - INTERNAL Functions #Region GHAPI.au3 - HOWTO / DOCS / HELP #CS https://developer.github.com/v3/ https://developer.github.com/v3/guides/ https://developer.github.com/program/ https://github.com/contact?form%5Bsubject%5D=New+GitHub+Integration https://developer.github.com/ http://stackoverflow.com/questions/28796941/github-api-authentication-with-msxml2-xmlhttp #CE #EndRegion GHAPI.au3 - HOWTO / DOCS / HELP  
      REMARKS:
      This is just a modest start up and not a whole fully workable UDF, just so for a try, but maybe someone will be useful
      Regards,
      mLipok
       
      EDIT 1:
      If you need to make it workable just ask about specyfic feature.
      EDIT 2:
      Some changes in using word "GitHub" - to meet this rules: https://github.com/logos
    • LeloDragneel
      By LeloDragneel
      Hey guys,
      I'm looking to implement an accurate voice recognition method in my program. I tried to understand the Microsoft SAPI API, read their online documentation and found it very confusing and unclear. (Like seriously, it's so bad and vague, but that's just my opinion). I have also tried using UTTER UDF, but could not get a grasp either, because you know, that's an extension UDF to Microsoft SAPI.
      Let's face it, the Google Speech Recognition is much more accurate than Microsoft SAPI (by far). Right now, I am determined to just use the Google Speech API. I have dug deep in regards to implementing the Google Speech API in AutoIT and I haven't found even one post about it. I suppose it's because the Google Speech API was only recently made available to the public. In case you don't know what I'm talking about, here's the link to google api. On that page, notice that there is language support for various languages such as Java, C#, and PHP. However, there's no support for AutoIT. So my question is; how can I go about implementing the Google Speech API into my AutoIT program? Is it even possible?
      Cheers guys!
    • mLipok
      By mLipok
      This is TeamViewer.au3 UDF for TeamViewer API.
       
      ; #INDEX# ======================================================================== ; Title .........: TeamViewer.au3 ; AutoIt Version : 3.3.10.2++ ; Language ......: English ; Description ...: A collection of function for use with TeamViewer API ; Author ........: mLipok ; Modified ......: ; URL ...........: ; URL ...........: https://www.teamviewer.com/ ; URL ...........: https://www.teamviewer.com/en/integrations/ ; URL ...........: https://integrate.teamviewer.com/en/develop/api/get-started/ ; URL ...........: https://downloadeu1.teamviewer.com/integrate/TeamViewer_API_Documentation.pdf ; Remarks .......: This UDF was created based on TeamViewer_API_Documentation.pdf v 1.4.1 ; Remarks .......: This UDF is using Free Chilkat component look here https://www.autoitscript.com/forum/files/file/433-chilkat-udf/ ; Remarks .......: Documentation is "work in progress" ; Date ..........: 2017/02/08 ; Version .......: 0.1.1 BETA - Work in progress ; ================================================================================  
      I'm using TeamViewer_Example.ini to store my secret tokens/keys.
      [Settings] AccessToken= [OAuth2] ClientID= ClientSecret= authorizationCode=  
      in TeamViewer_Example.au3 you can see few examples:
      Func _Example() ; If not exist then create new INI file from template If Not FileExists('TeamViewer_Example.ini') Then FileCopy('TeamViewer_Example — Template.ini', 'TeamViewer_Example.ini') ; Read Access Token from INI Local $sTV_AccessToken = IniRead('TeamViewer_Example.ini', 'Settings', 'AccessToken', '') If $sTV_AccessToken = '' Then ; Your Access Token, can be left empty when OAuth (below) is configured. ; ClientId = <----------------- Create an app in your TeamViewer Management Console and insert the client ID to the INI ; ClientSecret = <------------- Insert your client secret to the INI ; AuthorizationCode = <-------- Visit https://webapi.teamviewer.com/api/v1/oauth2/authorize?response_type=code&client_id=YOUR$i_ClientIdHERE ; Login, grant the permissions (popup) and put the code shown in the AuthorizationCode variable to the INI Local $sTVOAuth_ClientID = IniRead('TeamViewer_Example.ini', 'OAuth2', 'ClientID', '') Local $sTVOAuth_ClientSecret = IniRead('TeamViewer_Example.ini', 'OAuth2', 'ClientSecret', '') _IECreate('https://webapi.teamviewer.com/api/v1/oauth2/authorize?response_type=code&client_id=' & $sTVOAuth_ClientID) ; Local $sTVOAuth_AuthorizationCode = IniRead('TeamViewer_Example.ini', 'OAuth2', 'authorizationCode', '') Local $sTVOAuth_AuthorizationCode = InputBox('AuthorizationCode', 'Please provide TV OAuth2 AuthorizationCode') If @error Then Return If $sTVOAuth_ClientID Then $sTV_AccessToken = _TVAPI_RequestOAuth2_AccessToken($sTVOAuth_ClientID, $sTVOAuth_ClientSecret, $sTVOAuth_AuthorizationCode) EndIf If $sTV_AccessToken Then _TVAPI_AccessToken($sTV_AccessToken) If _TVAPI_Ping() = True Then ; ping API to check connection and $sTV_AccessToken _Example_TeamViewer__1_Devices_SaveToFile() ;~ _Example_TeamViewer__2_Devices_ChangeDetails() ;~ _Example_TeamViewer__3_Devices_GetDevicesSingleID() ;~ _Example_TeamViewer__4_Reports_GetAllConnections() ;~ _Example_TeamViewer__5_Users_GetUserInfomation() ;~ _Example_TeamViewer__6_Groups_ListGroups() ;~ _Example_TeamViewer__7_Devices_AddDeleteDevice() Else MsgBox(0, '_TVAPI_Ping', "$v_Token or connection problem.") EndIf EndFunc ;==>_Example  
      SUPPORT TOPIC IS HERE:
       
      TeamViewer_Example — Template.ini
    • mLipok
      By mLipok
      This is TeamViewer.au3 UDF for TeamViewer API.
      ; #INDEX# ======================================================================== ; Title .........: TeamViewer.au3 ; AutoIt Version : 3.3.10.2++ ; Language ......: English ; Description ...: A collection of function for use with TeamViewer API ; Author ........: mLipok ; Modified ......: ; URL ...........: ; URL ...........: https://www.teamviewer.com/ ; URL ...........: https://www.teamviewer.com/en/integrations/ ; URL ...........: https://integrate.teamviewer.com/en/develop/api/get-started/ ; URL ...........: https://downloadeu1.teamviewer.com/integrate/TeamViewer_API_Documentation.pdf ; Remarks .......: This UDF was created based on TeamViewer_API_Documentation.pdf v 1.4.1 ; Remarks .......: This UDF is using Free Chilkat component look here https://www.autoitscript.com/forum/files/file/433-chilkat-udf/ ; Remarks .......: Documentation is "work in progress" ; Date ..........: 2017/02/08 ; Version .......: 0.1.1 BETA - Work in progress ; ================================================================================ in TeamViewer_Example.au3 you can see few examples:

       
      Func _Example() ; If not exist then create new INI file from template If Not FileExists('TeamViewer_Example.ini') Then FileCopy('TeamViewer_Example — Template.ini', 'TeamViewer_Example.ini') ; Read Access Token from INI Local $sTV_AccessToken = IniRead('TeamViewer_Example.ini', 'Settings', 'AccessToken', '') If $sTV_AccessToken = '' Then ; Your Access Token, can be left empty when OAuth (below) is configured. ; ClientId = <----------------- Create an app in your TeamViewer Management Console and insert the client ID to the INI ; ClientSecret = <------------- Insert your client secret to the INI ; AuthorizationCode = <-------- Visit https://webapi.teamviewer.com/api/v1/oauth2/authorize?response_type=code&client_id=YOUR$i_ClientIdHERE ; Login, grant the permissions (popup) and put the code shown in the AuthorizationCode variable to the INI Local $sTVOAuth_ClientID = IniRead('TeamViewer_Example.ini', 'OAuth2', 'ClientID', '') Local $sTVOAuth_ClientSecret = IniRead('TeamViewer_Example.ini', 'OAuth2', 'ClientSecret', '') _IECreate('https://webapi.teamviewer.com/api/v1/oauth2/authorize?response_type=code&client_id=' & $sTVOAuth_ClientID) ; Local $sTVOAuth_AuthorizationCode = IniRead('TeamViewer_Example.ini', 'OAuth2', 'authorizationCode', '') Local $sTVOAuth_AuthorizationCode = InputBox('AuthorizationCode', 'Please provide TV OAuth2 AuthorizationCode') If @error Then Return If $sTVOAuth_ClientID Then $sTV_AccessToken = _TVAPI_RequestOAuth2_AccessToken($sTVOAuth_ClientID, $sTVOAuth_ClientSecret, $sTVOAuth_AuthorizationCode) EndIf If $sTV_AccessToken Then _TVAPI_AccessToken($sTV_AccessToken) If _TVAPI_Ping() = True Then ; ping API to check connection and $sTV_AccessToken _Example_TeamViewer__1_Devices_SaveToFile() ;~ _Example_TeamViewer__2_Devices_ChangeDetails() ;~ _Example_TeamViewer__3_Devices_GetDevicesSingleID() ;~ _Example_TeamViewer__4_Reports_GetAllConnections() ;~ _Example_TeamViewer__5_Users_GetUserInfomation() ;~ _Example_TeamViewer__6_Groups_ListGroups() ;~ _Example_TeamViewer__7_Devices_AddDeleteDevice() Else MsgBox(0, '_TVAPI_Ping', "$v_Token or connection problem.") EndIf EndFunc ;==>_Example You can download it here:
      I'm using TeamViewer_Example.ini to store my secret tokens/keys.
      [Settings] AccessToken= [OAuth2] ClientID= ClientSecret= authorizationCode=  
    • jandings
      By jandings
      Hello there,
      I'm trying to query a REST API of a webservice, SHOPWARE to be precise. The API is very well documented (https://developers.shopware.com/developers-guide/rest-api/#using-the-rest-api-in-your-own-a) but only using PHP. I tried some stuff but could not make it work.
      It should be very simple, because the following simply works in a Chrome-Browser:
      https://USERNAME:PASSPHRASE@www.SHOPWAREDOMAIN.com/api/orders/300
      queries me for username and passphrase and then dumps order number 300.
      Now I try to do the same in AutoIt (based on the wonderful work of many contributors here):
      #include-once #include "..\INCLUDE\winhttp.au3" #include "..\INCLUDE\OO_JSON.au3" ;Proxy Config Global $oJSON = _OO_JSON_Init() Global $obj = "" Global $sUserName = "USERNAME" Global $sPassword = "PASSPHRASE" Global $sDomain = "www.SHOPWAREDOMAIN.com/api/orders/300" Global $hOpen = _WinHttpOpen("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) JOC/0.1") ; without ie proxy settings $hConnect = _WinHttpConnect($hOpen, "https://" & $sDomain) ConsoleWrite ($hConnect & "#") $sReturned = _WinHttpSimpleSSLRequest($hConnect, "GET", $sUserName & ":" & $sPassword & "@" & $sDomain, Default ) ;$sReturned = _WinHttpSimpleSSLRequest($hConnect, "GET", $sDomain, Default, $sUserName & ":" & $sPassword) ;$sReturned = _WinHttpSimpleSSLRequest($hConnect, "GET", $sDomain, Default, , $sUserName & ":" & $sPassword ) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ; See what's returned ConsoleWrite ($sReturned & "#" & @error) Whatever version I use (I tried the commented ones and many others), I always get a reply from Shopware:
      {"success":false,"message":"Invalid or missing auth"}
      At least this comes from Shopware. But there must be some format of the credentials that I don't know or understand.
      Any help?