Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(AutoIt) MedTunnel: Send Message Text OnlySee more MedTunnel ExamplesDemonstrates the MedTunnel SendMessage method to send a message to one or more recipients. For more information, see https://server.medtunnel.com/apidocs/html/M_MedTunnelMsg_Controllers_MessageController_SendMessage.htm
; This example assumes the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. $oHttp = ObjCreate("Chilkat.Http") Local $bSuccess ; Implements the following CURL command: ; curl https://server.medtunnel.com/MedTunnelMsg/api/Message/SendMessage -X POST -k ; -F "ApplicationId=yourApplicationId" -F "LocationId=yourLocationId" ; -F "MedTunnelId=yourMedTunnelId" -F "MedTunnelPassword=yourMedTunnelPassword" ; -F "To=recipientsMedTunnelId" ; -F "Body=Test of SendMessage" ; Use the following online tool to generate HTTP code from a CURL command ; Convert a cURL Command to HTTP Source Code $oReq = ObjCreate("Chilkat.HttpRequest") $oReq.HttpVerb = "POST" $oReq.Path = "/MedTunnelMsg/api/Message/SendMessage" $oReq.ContentType = "multipart/form-data" $oReq.AddParam "ApplicationId","yourApplicationId" $oReq.AddParam "LocationId","yourLocationId" $oReq.AddParam "MedTunnelId","yourMedTunnelId" $oReq.AddParam "MedTunnelPassword","yourMedTunnelPassword" $oReq.AddParam "To","recipientsMedTunnelId" $oReq.AddParam "Body","Test" Local $oResp = $oHttp.SynchronousRequest("server.medtunnel.com",443,True,$oReq) If ($oHttp.LastMethodSuccess = False) Then ConsoleWrite($oHttp.LastErrorText & @CRLF) Exit EndIf $oSbResponseBody = ObjCreate("Chilkat.StringBuilder") $oResp.GetBodySb($oSbResponseBody) $oJResp = ObjCreate("Chilkat.JsonObject") $oJResp.LoadSb($oSbResponseBody) $oJResp.EmitCompact = False ConsoleWrite("Response Body:" & @CRLF) ConsoleWrite($oJResp.Emit() & @CRLF) Local $iRespStatusCode = $oResp.StatusCode ConsoleWrite("Response Status Code = " & $iRespStatusCode & @CRLF) If ($iRespStatusCode >= 400) Then ConsoleWrite("Response Header:" & @CRLF) ConsoleWrite($oResp.Header & @CRLF) ConsoleWrite("Failed." & @CRLF) Exit EndIf ; Sample JSON response: ; (Sample code for parsing the JSON response is shown below) ; { ; "ReturnCode": 1, ; "ReturnCodeText": "Success", ; "Data": "{\"Id\":989432,\"FromUserId\":36990,\"FromMailBoxId\":36965, ... \"SendGlobalNotifications\":false}" ; } ; Sample code for parsing the JSON response... ; Use the following online tool to generate parsing code from sample JSON: ; Generate Parsing Code from JSON Local $iReturnCode = $oJResp.IntOf("ReturnCode") Local $sReturnCodeText = $oJResp.StringOf("ReturnCodeText") Local $sData = $oJResp.StringOf("Data") ; Load the Data into another JSON object and parse.. $oJsonData = ObjCreate("Chilkat.JsonObject") $oJsonData.Load($sData) $oJsonData.EmitCompact = False ConsoleWrite($oJsonData.Emit() & @CRLF) ; { ; "Id": 989436, ; "FromUserId": 36990, ; "FromMailBoxId": 36965, ; "FromUserType": 0, ; "FromUserName": "...", ; "FromUserFullName": "...", ; "FromUserAccountName": "...", ; "FromUserAccountTitle": "...", ; "ToUserId": 36990, ; "ToUserType": 1, ; "ToUserMailboxId": "36965", ; "ToUserName": "...", ; "ToUserFullName": "...", ; "EmailAddress": "", ; "Password": "", ; "Subject": "", ; "PatientMedTunnelId": "", ; "Body": "Test", ; "DateReceived": "4/29/2021 2:29:18 PM", ; "DisplayDateReceived": "04/29/2021 2:29 PM", ; "ViewCount": 0, ; "ViewedOn": "", ; "AttachmentCount": 0, ; "AttachmentNames": [ ; ], ; "AllRecipients": [ ; { ; "Id": 989436, ; "UserName": "...", ; "AccountId": 0, ; "AccountName": "...", ; "AccountTitle": "", ; "FirstName": "...", ; "LastName": "...", ; "EmailAddress": "", ; "LastSentOn": "", ; "SendCount": 0, ; "IsFavorite": false ; } ; ], ; "Status": 1, ; "ParentMessageId": 989436, ; "DistributionListId": 0, ; "DistributionListName": "", ; "BodyHistory": "", ; "ReadReceiptCallbackUrl": null, ; "SendGlobalNotifications": false ; } ; Local $sUserName Local $iAccountId Local $sAccountName Local $sAccountTitle Local $sFirstName Local $sLastName Local $sLastSentOn Local $iSendCount Local $bIsFavorite Local $iId = $oJsonData.IntOf("Id") Local $iFromUserId = $oJsonData.IntOf("FromUserId") Local $iFromMailBoxId = $oJsonData.IntOf("FromMailBoxId") Local $iFromUserType = $oJsonData.IntOf("FromUserType") Local $sFromUserName = $oJsonData.StringOf("FromUserName") Local $sFromUserFullName = $oJsonData.StringOf("FromUserFullName") Local $sFromUserAccountName = $oJsonData.StringOf("FromUserAccountName") Local $sFromUserAccountTitle = $oJsonData.StringOf("FromUserAccountTitle") Local $iToUserId = $oJsonData.IntOf("ToUserId") Local $iToUserType = $oJsonData.IntOf("ToUserType") Local $sToUserMailboxId = $oJsonData.StringOf("ToUserMailboxId") Local $sToUserName = $oJsonData.StringOf("ToUserName") Local $sToUserFullName = $oJsonData.StringOf("ToUserFullName") Local $sEmailAddress = $oJsonData.StringOf("EmailAddress") Local $sPassword = $oJsonData.StringOf("Password") Local $sSubject = $oJsonData.StringOf("Subject") Local $sPatientMedTunnelId = $oJsonData.StringOf("PatientMedTunnelId") Local $sBody = $oJsonData.StringOf("Body") Local $sDateReceived = $oJsonData.StringOf("DateReceived") Local $sDisplayDateReceived = $oJsonData.StringOf("DisplayDateReceived") Local $iViewCount = $oJsonData.IntOf("ViewCount") Local $sViewedOn = $oJsonData.StringOf("ViewedOn") Local $iAttachmentCount = $oJsonData.IntOf("AttachmentCount") Local $iStatus = $oJsonData.IntOf("Status") Local $iParentMessageId = $oJsonData.IntOf("ParentMessageId") Local $iDistributionListId = $oJsonData.IntOf("DistributionListId") Local $sDistributionListName = $oJsonData.StringOf("DistributionListName") Local $sBodyHistory = $oJsonData.StringOf("BodyHistory") Local $sReadReceiptCallbackUrl = $oJsonData.StringOf("ReadReceiptCallbackUrl") Local $bSendGlobalNotifications = $oJsonData.BoolOf("SendGlobalNotifications") Local $i = 0 Local $iCount_i = $oJsonData.SizeOfArray("AttachmentNames") While $i < $iCount_i $oJsonData.I = $i $i = $i + 1 Wend $i = 0 $iCount_i = $oJsonData.SizeOfArray("AllRecipients") While $i < $iCount_i $oJsonData.I = $i $iId = $oJsonData.IntOf("AllRecipients[i].Id") $sUserName = $oJsonData.StringOf("AllRecipients[i].UserName") $iAccountId = $oJsonData.IntOf("AllRecipients[i].AccountId") $sAccountName = $oJsonData.StringOf("AllRecipients[i].AccountName") $sAccountTitle = $oJsonData.StringOf("AllRecipients[i].AccountTitle") $sFirstName = $oJsonData.StringOf("AllRecipients[i].FirstName") $sLastName = $oJsonData.StringOf("AllRecipients[i].LastName") $sEmailAddress = $oJsonData.StringOf("AllRecipients[i].EmailAddress") $sLastSentOn = $oJsonData.StringOf("AllRecipients[i].LastSentOn") $iSendCount = $oJsonData.IntOf("AllRecipients[i].SendCount") $bIsFavorite = $oJsonData.BoolOf("AllRecipients[i].IsFavorite") $i = $i + 1 Wend |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.