Jump to content
Moxom160

Problem with SOAP with Attachment

Recommended Posts

Moxom160

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
Melba23

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
Moxom160

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
Melba23

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
trancexx

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
Moxom160

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
trancexx

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
Moxom160

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
trancexx

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.

  • Like 1

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
Moxom160

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
trancexx

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
trancexx

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
trancexx

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
Moxom160

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
mLipok

@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 UDF * 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 * Good coding practices in AutoIt * 

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: 2018-03-17

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

    • rcmaehl
      By rcmaehl
      Hi all, 

      Recently my work swapped from Cisco CTIOS to Finesse. This completely threw me off as I had been automating the Win32 application and I had never done IUIAutomation before. As such I've been messing around with the API and will be adding code as I figure it out. While I do have Supervisor access, I will likely not be adding functions for those features yet.
      Currently Available Functions:

      Changelog:

      Changes I'm Thinking About
       
      Download:
       
       
    • Iznogoud
      By Iznogoud
      Hi,
      I was wondering if someone can help me to create an AutoIT script which can create a ticket in a TopDesk environment.
      The API is wel documented, but i have not enough knowlegde at this moment to get this up from the ground. If someone could help me or if i could hire / pay someone to help me with this, that would be great.
      Information about the API can be found here: https://developers.topdesk.com/
      Is there a place where i maybe can hire AutoIT professionals to help me with this?
      On freelancer.com is an option, but there are alot of people responding which doesn't know a thing about AutoIT.
    • Ascer
      By Ascer
      1. Description.
      oAuth 2.0 is security system implemented by Google a few years ago. You are able to connect into your Google accounts and manage documents. In this UDF i show you how to pass first authorization process., this allow you to automate most of functions using API interface. 2. Requirements.
      Google account. oAuth.au3 Download 3. Possibilities
      ;============================================================================================================ ; Date: 2018-02-10, 14:21 ; ; Description: UDF for authorize your app with oAuth 2.0 Google. ; ; Function(s): ; oAuth2GetAuthorizationCode() -> Get Code for "grant". ; oAuth2GetAccessToken() -> Get "access_token" and "refresh_token" first time. ; oAuth2RefreshAccessToken() -> Get current "access_token" using "refresh_token". ; ; Author(s): Ascer ;============================================================================================================ 4. Enable your Google API.
          4.1. Video Tutorial not mine!
       YouTube     4.2 Screenshots from authorization process (Polish language) 
      Go to https://console.developers.google.com/apis/dashboard and accept current rules.  

       
      Next create an new project  

       
      Enter name of you new project and click Create  

       
      Google will working now, please wait until finish. Next go to enable your API interface, we make if for Google  

       
      Take "Gmail" in search input and after click in found result.  

       
      Click Enable interface, Google will working now.  

       
      Create your login credentials  

       
      Select Windows Interface (combobox), User credentials (radio) and click button what is need bla bla  

       
      Type name of a new client id for oAuth 2.0 and click Create a new Client ID.  

       
      Next configure screen aplication, type some name and click Next. Google will working now.  

       
      Last step on this website is download source with your credentials in *Json format.  

       
      Now you received a file named client_id.json, it's how it look in Sublime Text:  

       
      5. Coding.
      Now we need to call a some function to get access code.  
      #include <oAuth.au3> Local $sClientId = "167204758184-vpeues0uk6b0g4jrnv0ipq5fapoig2v8.apps.googleusercontent.com" Local $sRedirectUri = "http://localhost" oAuth2GetAuthorizationCode($sClientId, $sRedirectUri)  
      Function will execute default browser for ask you to permission.  

       
      Next Google ask you to permission for access to your personal details by application Autoit   

       
      Now you can thing is something wrong but all is ok, you need to copy all after  code= . It your access code.  

       
      Let's now ask Google about our Access Token and Refresh Token  
      #include <oAuth.au3> Local $sClientId = "167204758184-vpeues0uk6b0g4jrnv0ipq5fapoig2v8.apps.googleusercontent.com" Local $sClientSecret = "cWalvFr3WxiE6cjUkdmKEPo8" Local $sAuthorizationCode = "4/AAAPXJOZ-Tz0s6mrx7JbV6nthXSfcxaszFh_aH0azVqHkSHkfiwE8uamcabn4eMbEWg1eAuUw7AU0PQ0XeWUFRo#" Local $sRedirectUri = "http://localhost" Local $aRet = oAuth2GetAccessToken($sClientId, $sClientSecret, $sAuthorizationCode, $sRedirectUri) If Ubound($aRet) <> 4 then ConsoleWrite("+++ Something wrong with reading ResponseText." & @CRLF) Exit EndIf ConsoleWrite("Successfully received data from Google." & @CRLF) ConsoleWrite("access_token: " & $aRet[0] & @CRLF) ConsoleWrite("expires_in: " & $aRet[1] & @CRLF) ConsoleWrite("refresh_token: " & $aRet[2] & @CRLF) ConsoleWrite("token_type: " & $aRet[3] & @CRLF)  
      Important! When you received error 400 and output says: Invalid grant it means that your previous generated access_code lost validity and you need to generate new calling previus code. When everything is fine you should received a 4 informations about your: access_token, expires_in, refresh_token and token_type. Access_Token time is a little short so you need to know fuction possible to refresh it (tell Google that he should generate a new Token for you)  
      #include <oAuth.au3> Local $sRefreshToken = "1/ba8JpW7TjQH3-UI1BvPaXhSf-oTQ4BmZAbBfhcKgKfY" Local $sClientId = "167204758184-vpeues0uk6b0g4jrnv0ipq5fapoig2v8.apps.googleusercontent.com" Local $sClientSecret = "cWalvFr3WxiE6cjUkdmKEPo8" Local $sRedirectUri = "http://localhost" Local $aRet = oAuth2RefreshAccessToken($sRefreshToken, $sClientId, $sClientSecret) If Ubound($aRet) <> 3 then ConsoleWrite("+++ Something wrong with reading ResponseText." & @CRLF) Exit EndIf ConsoleWrite("Successfully received data from Google." & @CRLF) ConsoleWrite("access_token: " & $aRet[0] & @CRLF) ConsoleWrite("expires_in: " & $aRet[1] & @CRLF) ConsoleWrite("token_type: " & $aRet[2] & @CRLF)  
      6. Finish words
      If you followed all this above steps im sure that you received all informations required for coding your Google API (Gmail, Dropbox, YouTube, Calender etc. See next thread: [UDF] Gmail API - Email automation with AutoIt!
    • Ascer
      By Ascer
      1. Description.
      Automate communication with Gmail API using oAuth 2.0 security. 2. Requirements.
      Google Gmail account. Finished Authorization process. Look here 3. Possibilities.
      ;======================================================================================================================== ; Date: 2018-02-12, 11:46 ; ; Bug Fixs: 2018-02-17, 7:31 -> Fixed problems with adding items to array and minor bugs. ; ; Description: UDF for using Gmail API interface. This UDF requires oAuth.au3 and Gmail account. ; ; Function(s): ; gmailUsersGetProfile() -> Information about your account. ; gmailUsersLabelsList() -> Get all available labels ids. ex. "INBOX", "UNREAD" ; gmailUsersLabelsGet() -> Get information about specific label id. ; gmailUsersMessagesBatchDelete() -> Delete many messages emails by id. ; gmailUsersMessagesBatchModify() -> Set status for many messages ex. "INBOX", "UNREAD" ; gmailUsersMessagesDelete() -> Totaly delete email from ur account. ; gmailUsersMessagesGet() -> Get all information about specific email. ; gmailUsersMessagesList() -> Get list of last ~100 emails. ; gmailUsersMessagesModify() -> Modify single message. ; gmailUsersMessagesTrash() -> Put email in trash. ; gmailUsersMessagesUntrash() -> Restore email from trash. ; gmailUsersMessagesSend() -> Send email to single or group recipients. ; gmailUsersMessagesAttachmentsGet() -> Download attachment by id. ; ; Author(s): Ascer ;======================================================================================================================== 4. Downloads.
      oAuth.au3 Gmail API.au3 5. Examples.
      Sending emails
    • islandspapand
      By islandspapand
      Hi All
      i am currently trying to add a function to my project that can send SMS, i have gone with Twilio for the sms service that use a REST API.
      I have never worked with an API before, and could use some help.
      I can get my function working with using cURL.exe and copy past command from the website with the following code. And thats great unfortunately i am have issue with character like æøå when sending a SMS appears like a box or ?. this does not happen if i do it from the website so it looks like a Unicode issue in curl.exe.
      I have done some searching on the forum and understand that i should be able to implement this curl command with the WinHTTP UDF from @trancexx so i don't need a third part exe and it might fix my charater issue.
      Unfortunately i really don't understand how i am to change curl commands to the WinHTTP and i was hoping some good maybe give me an example i could learn from.
      Thanks in advanced
      i have removed the AuthToken number from the script.
      _SendSMS("00000000","SomeOne","SMS body info") Func _SendSMS($SendTo,$SendFrom,$Msgtxt) $AccountSID = "ACbb765b3180d5938229eff8b8f63ed1bc" $AuthToken = "Auth Token number" $Data = '"https://api.twilio.com/2010-04-01/Accounts/'&$AccountSID&'/Messages.json"'& _ '-X POST \ --data-urlencode "To=+45'&$SendTo&'" \ --data-urlencode "From='&$SendFrom&'" \ --data-urlencode "Body='&$Msgtxt&'" \ -u '&$AccountSID&':'&$AuthToken&'' ShellExecute(@ScriptDir&"\curl.exe","-k "&$Data) ;~ curl 'https://api.twilio.com/2010-04-01/Accounts/ACbb765b3180d5938229eff8b8f63ed1bc/Messages.json' -X POST \ ;~ --data-urlencode 'To=+4500000000' \ ;~ --data-urlencode 'From=Reception' \ ;~ --data-urlencode 'Body=Test Body' \ ;~ -u ACbb765b3180d5938229eff8b8f63ed1bc:[AuthToken] EndFunc  
       
×