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
(Visual FoxPro) 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
LOCAL loHttp LOCAL lnSuccess LOCAL loReq LOCAL loResp LOCAL loSbResponseBody LOCAL loJResp LOCAL lnRespStatusCode LOCAL lnReturnCode LOCAL lcReturnCodeText LOCAL lcData LOCAL loJsonData LOCAL lcUserName LOCAL lnAccountId LOCAL lcAccountName LOCAL lcAccountTitle LOCAL lcFirstName LOCAL lcLastName LOCAL lcLastSentOn LOCAL lnSendCount LOCAL lnIsFavorite LOCAL lnId LOCAL lnFromUserId LOCAL lnFromMailBoxId LOCAL lnFromUserType LOCAL lcFromUserName LOCAL lcFromUserFullName LOCAL lcFromUserAccountName LOCAL lcFromUserAccountTitle LOCAL lnToUserId LOCAL lnToUserType LOCAL lcToUserMailboxId LOCAL lcToUserName LOCAL lcToUserFullName LOCAL lcEmailAddress LOCAL lcPassword LOCAL lcSubject LOCAL lcPatientMedTunnelId LOCAL lcBody LOCAL lcDateReceived LOCAL lcDisplayDateReceived LOCAL lnViewCount LOCAL lcViewedOn LOCAL lnAttachmentCount LOCAL lnStatus LOCAL lnParentMessageId LOCAL lnDistributionListId LOCAL lcDistributionListName LOCAL lcBodyHistory LOCAL lcReadReceiptCallbackUrl LOCAL lnSendGlobalNotifications LOCAL i LOCAL lnCount_i * This example assumes the Chilkat API to have been previously unlocked. * See Global Unlock Sample for sample code. * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http') loHttp = CreateObject('Chilkat.Http') * 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 * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.HttpRequest') loReq = CreateObject('Chilkat.HttpRequest') loReq.HttpVerb = "POST" loReq.Path = "/MedTunnelMsg/api/Message/SendMessage" loReq.ContentType = "multipart/form-data" loReq.AddParam("ApplicationId","yourApplicationId") loReq.AddParam("LocationId","yourLocationId") loReq.AddParam("MedTunnelId","yourMedTunnelId") loReq.AddParam("MedTunnelPassword","yourMedTunnelPassword") loReq.AddParam("To","recipientsMedTunnelId") loReq.AddParam("Body","Test") loResp = loHttp.SynchronousRequest("server.medtunnel.com",443,1,loReq) IF (loHttp.LastMethodSuccess = 0) THEN ? loHttp.LastErrorText RELEASE loHttp RELEASE loReq CANCEL ENDIF * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder') loSbResponseBody = CreateObject('Chilkat.StringBuilder') loResp.GetBodySb(loSbResponseBody) * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject') loJResp = CreateObject('Chilkat.JsonObject') loJResp.LoadSb(loSbResponseBody) loJResp.EmitCompact = 0 ? "Response Body:" ? loJResp.Emit() lnRespStatusCode = loResp.StatusCode ? "Response Status Code = " + STR(lnRespStatusCode) IF (lnRespStatusCode >= 400) THEN ? "Response Header:" ? loResp.Header ? "Failed." RELEASE loResp RELEASE loHttp RELEASE loReq RELEASE loSbResponseBody RELEASE loJResp CANCEL ENDIF RELEASE loResp * 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 lnReturnCode = loJResp.IntOf("ReturnCode") lcReturnCodeText = loJResp.StringOf("ReturnCodeText") lcData = loJResp.StringOf("Data") * Load the Data into another JSON object and parse.. * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject') loJsonData = CreateObject('Chilkat.JsonObject') loJsonData.Load(lcData) loJsonData.EmitCompact = 0 ? loJsonData.Emit() * { * "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 * } * lnId = loJsonData.IntOf("Id") lnFromUserId = loJsonData.IntOf("FromUserId") lnFromMailBoxId = loJsonData.IntOf("FromMailBoxId") lnFromUserType = loJsonData.IntOf("FromUserType") lcFromUserName = loJsonData.StringOf("FromUserName") lcFromUserFullName = loJsonData.StringOf("FromUserFullName") lcFromUserAccountName = loJsonData.StringOf("FromUserAccountName") lcFromUserAccountTitle = loJsonData.StringOf("FromUserAccountTitle") lnToUserId = loJsonData.IntOf("ToUserId") lnToUserType = loJsonData.IntOf("ToUserType") lcToUserMailboxId = loJsonData.StringOf("ToUserMailboxId") lcToUserName = loJsonData.StringOf("ToUserName") lcToUserFullName = loJsonData.StringOf("ToUserFullName") lcEmailAddress = loJsonData.StringOf("EmailAddress") lcPassword = loJsonData.StringOf("Password") lcSubject = loJsonData.StringOf("Subject") lcPatientMedTunnelId = loJsonData.StringOf("PatientMedTunnelId") lcBody = loJsonData.StringOf("Body") lcDateReceived = loJsonData.StringOf("DateReceived") lcDisplayDateReceived = loJsonData.StringOf("DisplayDateReceived") lnViewCount = loJsonData.IntOf("ViewCount") lcViewedOn = loJsonData.StringOf("ViewedOn") lnAttachmentCount = loJsonData.IntOf("AttachmentCount") lnStatus = loJsonData.IntOf("Status") lnParentMessageId = loJsonData.IntOf("ParentMessageId") lnDistributionListId = loJsonData.IntOf("DistributionListId") lcDistributionListName = loJsonData.StringOf("DistributionListName") lcBodyHistory = loJsonData.StringOf("BodyHistory") lcReadReceiptCallbackUrl = loJsonData.StringOf("ReadReceiptCallbackUrl") lnSendGlobalNotifications = loJsonData.BoolOf("SendGlobalNotifications") i = 0 lnCount_i = loJsonData.SizeOfArray("AttachmentNames") DO WHILE i < lnCount_i loJsonData.I = i i = i + 1 ENDDO i = 0 lnCount_i = loJsonData.SizeOfArray("AllRecipients") DO WHILE i < lnCount_i loJsonData.I = i lnId = loJsonData.IntOf("AllRecipients[i].Id") lcUserName = loJsonData.StringOf("AllRecipients[i].UserName") lnAccountId = loJsonData.IntOf("AllRecipients[i].AccountId") lcAccountName = loJsonData.StringOf("AllRecipients[i].AccountName") lcAccountTitle = loJsonData.StringOf("AllRecipients[i].AccountTitle") lcFirstName = loJsonData.StringOf("AllRecipients[i].FirstName") lcLastName = loJsonData.StringOf("AllRecipients[i].LastName") lcEmailAddress = loJsonData.StringOf("AllRecipients[i].EmailAddress") lcLastSentOn = loJsonData.StringOf("AllRecipients[i].LastSentOn") lnSendCount = loJsonData.IntOf("AllRecipients[i].SendCount") lnIsFavorite = loJsonData.BoolOf("AllRecipients[i].IsFavorite") i = i + 1 ENDDO RELEASE loHttp RELEASE loReq RELEASE loSbResponseBody RELEASE loJResp RELEASE loJsonData |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.