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
(DataFlex) 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
Use ChilkatAx-win32.pkg Procedure Test Handle hoHttp Boolean iSuccess Variant vReq Handle hoReq Variant vResp Handle hoResp Variant vSbResponseBody Handle hoSbResponseBody Handle hoJResp Integer iRespStatusCode Integer iReturnCode String sReturnCodeText String sData Handle hoJsonData String sUserName Integer iAccountId String sAccountName String sAccountTitle String sFirstName String sLastName String sLastSentOn Integer iSendCount Boolean iIsFavorite Integer iId Integer iFromUserId Integer iFromMailBoxId Integer iFromUserType String sFromUserName String sFromUserFullName String sFromUserAccountName String sFromUserAccountTitle Integer iToUserId Integer iToUserType String sToUserMailboxId String sToUserName String sToUserFullName String sEmailAddress String sPassword String sSubject String sPatientMedTunnelId String sBody String sDateReceived String sDisplayDateReceived Integer iViewCount String sViewedOn Integer iAttachmentCount Integer iStatus Integer iParentMessageId Integer iDistributionListId String sDistributionListName String sBodyHistory String sReadReceiptCallbackUrl Boolean iSendGlobalNotifications Integer i Integer iCount_i String sTemp1 Boolean bTemp1 // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. Get Create (RefClass(cComChilkatHttp)) To hoHttp If (Not(IsComObjectCreated(hoHttp))) Begin Send CreateComObject of hoHttp End // 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 Get Create (RefClass(cComChilkatHttpRequest)) To hoReq If (Not(IsComObjectCreated(hoReq))) Begin Send CreateComObject of hoReq End Set ComHttpVerb Of hoReq To "POST" Set ComPath Of hoReq To "/MedTunnelMsg/api/Message/SendMessage" Set ComContentType Of hoReq To "multipart/form-data" Send ComAddParam To hoReq "ApplicationId" "yourApplicationId" Send ComAddParam To hoReq "LocationId" "yourLocationId" Send ComAddParam To hoReq "MedTunnelId" "yourMedTunnelId" Send ComAddParam To hoReq "MedTunnelPassword" "yourMedTunnelPassword" Send ComAddParam To hoReq "To" "recipientsMedTunnelId" Send ComAddParam To hoReq "Body" "Test" Get pvComObject of hoReq to vReq Get ComSynchronousRequest Of hoHttp "server.medtunnel.com" 443 True vReq To vResp If (IsComObject(vResp)) Begin Get Create (RefClass(cComChilkatHttpResponse)) To hoResp Set pvComObject Of hoResp To vResp End Get ComLastMethodSuccess Of hoHttp To bTemp1 If (bTemp1 = False) Begin Get ComLastErrorText Of hoHttp To sTemp1 Showln sTemp1 Procedure_Return End Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody If (Not(IsComObjectCreated(hoSbResponseBody))) Begin Send CreateComObject of hoSbResponseBody End Get pvComObject of hoSbResponseBody to vSbResponseBody Get ComGetBodySb Of hoResp vSbResponseBody To iSuccess Get Create (RefClass(cComChilkatJsonObject)) To hoJResp If (Not(IsComObjectCreated(hoJResp))) Begin Send CreateComObject of hoJResp End Get pvComObject of hoSbResponseBody to vSbResponseBody Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess Set ComEmitCompact Of hoJResp To False Showln "Response Body:" Get ComEmit Of hoJResp To sTemp1 Showln sTemp1 Get ComStatusCode Of hoResp To iRespStatusCode Showln "Response Status Code = " iRespStatusCode If (iRespStatusCode >= 400) Begin Showln "Response Header:" Get ComHeader Of hoResp To sTemp1 Showln sTemp1 Showln "Failed." Send Destroy of hoResp Procedure_Return End Send Destroy of hoResp // 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 Get ComIntOf Of hoJResp "ReturnCode" To iReturnCode Get ComStringOf Of hoJResp "ReturnCodeText" To sReturnCodeText Get ComStringOf Of hoJResp "Data" To sData // Load the Data into another JSON object and parse.. Get Create (RefClass(cComChilkatJsonObject)) To hoJsonData If (Not(IsComObjectCreated(hoJsonData))) Begin Send CreateComObject of hoJsonData End Get ComLoad Of hoJsonData sData To iSuccess Set ComEmitCompact Of hoJsonData To False Get ComEmit Of hoJsonData To sTemp1 Showln sTemp1 // { // "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 // } // Get ComIntOf Of hoJsonData "Id" To iId Get ComIntOf Of hoJsonData "FromUserId" To iFromUserId Get ComIntOf Of hoJsonData "FromMailBoxId" To iFromMailBoxId Get ComIntOf Of hoJsonData "FromUserType" To iFromUserType Get ComStringOf Of hoJsonData "FromUserName" To sFromUserName Get ComStringOf Of hoJsonData "FromUserFullName" To sFromUserFullName Get ComStringOf Of hoJsonData "FromUserAccountName" To sFromUserAccountName Get ComStringOf Of hoJsonData "FromUserAccountTitle" To sFromUserAccountTitle Get ComIntOf Of hoJsonData "ToUserId" To iToUserId Get ComIntOf Of hoJsonData "ToUserType" To iToUserType Get ComStringOf Of hoJsonData "ToUserMailboxId" To sToUserMailboxId Get ComStringOf Of hoJsonData "ToUserName" To sToUserName Get ComStringOf Of hoJsonData "ToUserFullName" To sToUserFullName Get ComStringOf Of hoJsonData "EmailAddress" To sEmailAddress Get ComStringOf Of hoJsonData "Password" To sPassword Get ComStringOf Of hoJsonData "Subject" To sSubject Get ComStringOf Of hoJsonData "PatientMedTunnelId" To sPatientMedTunnelId Get ComStringOf Of hoJsonData "Body" To sBody Get ComStringOf Of hoJsonData "DateReceived" To sDateReceived Get ComStringOf Of hoJsonData "DisplayDateReceived" To sDisplayDateReceived Get ComIntOf Of hoJsonData "ViewCount" To iViewCount Get ComStringOf Of hoJsonData "ViewedOn" To sViewedOn Get ComIntOf Of hoJsonData "AttachmentCount" To iAttachmentCount Get ComIntOf Of hoJsonData "Status" To iStatus Get ComIntOf Of hoJsonData "ParentMessageId" To iParentMessageId Get ComIntOf Of hoJsonData "DistributionListId" To iDistributionListId Get ComStringOf Of hoJsonData "DistributionListName" To sDistributionListName Get ComStringOf Of hoJsonData "BodyHistory" To sBodyHistory Get ComStringOf Of hoJsonData "ReadReceiptCallbackUrl" To sReadReceiptCallbackUrl Get ComBoolOf Of hoJsonData "SendGlobalNotifications" To iSendGlobalNotifications Move 0 To i Get ComSizeOfArray Of hoJsonData "AttachmentNames" To iCount_i While (i < iCount_i) Set ComI Of hoJsonData To i Move (i + 1) To i Loop Move 0 To i Get ComSizeOfArray Of hoJsonData "AllRecipients" To iCount_i While (i < iCount_i) Set ComI Of hoJsonData To i Get ComIntOf Of hoJsonData "AllRecipients[i].Id" To iId Get ComStringOf Of hoJsonData "AllRecipients[i].UserName" To sUserName Get ComIntOf Of hoJsonData "AllRecipients[i].AccountId" To iAccountId Get ComStringOf Of hoJsonData "AllRecipients[i].AccountName" To sAccountName Get ComStringOf Of hoJsonData "AllRecipients[i].AccountTitle" To sAccountTitle Get ComStringOf Of hoJsonData "AllRecipients[i].FirstName" To sFirstName Get ComStringOf Of hoJsonData "AllRecipients[i].LastName" To sLastName Get ComStringOf Of hoJsonData "AllRecipients[i].EmailAddress" To sEmailAddress Get ComStringOf Of hoJsonData "AllRecipients[i].LastSentOn" To sLastSentOn Get ComIntOf Of hoJsonData "AllRecipients[i].SendCount" To iSendCount Get ComBoolOf Of hoJsonData "AllRecipients[i].IsFavorite" To iIsFavorite Move (i + 1) To i Loop End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.