Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

DataFlex Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Google Vision
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
JCC Cyprus
Jira
Lightspeed
MYOB
Magento
Mailgun
Malaysia MyInvois

Mastercard
MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
Salesforce
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
TikTok Shop
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(DataFlex) MedTunnel: Send Message Text Only

See more MedTunnel Examples

Demonstrates 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

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

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.