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
(Lianja) 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. loHttp = createobject("CkHttp") // 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 loReq = createobject("CkHttpRequest") 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,.T.,loReq) if (loHttp.LastMethodSuccess = .F.) then ? loHttp.LastErrorText release loHttp release loReq return endif loSbResponseBody = createobject("CkStringBuilder") loResp.GetBodySb(loSbResponseBody) loJResp = createobject("CkJsonObject") loJResp.LoadSb(loSbResponseBody) loJResp.EmitCompact = .F. ? "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 return 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.. loJsonData = createobject("CkJsonObject") loJsonData.Load(lcData) loJsonData.EmitCompact = .F. ? 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") llSendGlobalNotifications = 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") llIsFavorite = 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.