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) MessageMedia - Send Messages

See more MessageMedia Examples

Submit one or more (up to 100 per request) SMS, MMS, or text to voice messages for delivery.

For more information, see https://support.messagemedia.com/hc/en-us/articles/4413635760527-Messaging-API

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vJson
    Handle hoJson
    Variant vResp
    Handle hoResp
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJResp
    Integer iRespStatusCode
    String sMessage_id
    String sCallback_url
    String sStatus
    String sContent
    String sDestination_number
    Boolean iDelivery_report
    String sFormat
    String sMessage_expiry_timestamp
    String sMyKey
    String sAnotherKey
    String sScheduled
    String sSource_number
    String sSource_number_type
    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 --request POST \
    //      --header "Content-Type: application/json" \
    //      --header "Accept: application/json" \
    //      --data-binary "{
    //     \"messages\": [
    //         {
    //             \"callback_url\": \"https://my.callback.url.com\",
    //             \"content\": \"My first message\",
    //             \"destination_number\": \"+61491570156\",
    //             \"delivery_report\": true,
    //             \"format\": \"SMS\",
    //             \"message_expiry_timestamp\": \"2016-11-03T11:49:02.807Z\",
    //             \"metadata\": {
    //                 \"myKey\": \"myValue\",
    //                 \"anotherKey\": \"anotherValue\"
    //             },
    //             \"scheduled\": \"2016-11-03T11:49:02.807Z\",
    //             \"source_number\": \"+61491570157\",
    //             \"source_number_type\": \"INTERNATIONAL\"
    //         },
    //         {
    //             \"callback_url\": \"https://my.callback.url.com\",
    //             \"content\": \"My second message\",
    //             \"destination_number\": \"+61491570158\",
    //             \"delivery_report\": true,
    //             \"format\": \"MMS\",
    //             \"subject\": \"This is an MMS message\",
    //             \"media\": [ \"https://images.pexels.com/photos/1018350/pexels-photo-1018350.jpeg?cs=srgb&dl=architecture-buildings-city-1018350.jpg\" ],
    //             \"message_expiry_timestamp\": \"2016-11-03T11:49:02.807Z\",
    //             \"metadata\": {
    //                 \"myKey\": \"myValue\",
    //                 \"anotherKey\": \"anotherValue\"
    //             },
    //             \"scheduled\": \"2016-11-03T11:49:02.807Z\",
    //             \"source_number\": \"+61491570159\",
    //             \"source_number_type\": \"INTERNATIONAL\"
    //         }
    //     ]
    // }" \
    // https://private-anon-ecbaffbc28-messages32.apiary-mock.com/v1/messages

    // Use the following online tool to generate HTTP code from a CURL command
    // Convert a cURL Command to HTTP Source Code

    // Use this online tool to generate code from sample JSON:
    // Generate Code to Create JSON

    // The following JSON is sent in the request body.

    // {
    //   "messages": [
    //     {
    //       "callback_url": "https://my.callback.url.com",
    //       "content": "My first message",
    //       "destination_number": "+61491570156",
    //       "delivery_report": true,
    //       "format": "SMS",
    //       "message_expiry_timestamp": "2016-11-03T11:49:02.807Z",
    //       "metadata": {
    //         "myKey": "myValue",
    //         "anotherKey": "anotherValue"
    //       },
    //       "scheduled": "2016-11-03T11:49:02.807Z",
    //       "source_number": "+61491570157",
    //       "source_number_type": "INTERNATIONAL"
    //     },
    //     {
    //       "callback_url": "https://my.callback.url.com",
    //       "content": "My second message",
    //       "destination_number": "+61491570158",
    //       "delivery_report": true,
    //       "format": "MMS",
    //       "subject": "This is an MMS message",
    //       "media": [
    //         "https://images.pexels.com/photos/1018350/pexels-photo-1018350.jpeg?cs=srgb&dl=architecture-buildings-city-1018350.jpg"
    //       ],
    //       "message_expiry_timestamp": "2016-11-03T11:49:02.807Z",
    //       "metadata": {
    //         "myKey": "myValue",
    //         "anotherKey": "anotherValue"
    //       },
    //       "scheduled": "2016-11-03T11:49:02.807Z",
    //       "source_number": "+61491570159",
    //       "source_number_type": "INTERNATIONAL"
    //     }
    //   ]
    // }

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComUpdateString Of hoJson "messages[0].callback_url" "https://my.callback.url.com" To iSuccess
    Get ComUpdateString Of hoJson "messages[0].content" "My first message" To iSuccess
    Get ComUpdateString Of hoJson "messages[0].destination_number" "+61491570156" To iSuccess
    Get ComUpdateBool Of hoJson "messages[0].delivery_report" True To iSuccess
    Get ComUpdateString Of hoJson "messages[0].format" "SMS" To iSuccess
    Get ComUpdateString Of hoJson "messages[0].message_expiry_timestamp" "2016-11-03T11:49:02.807Z" To iSuccess
    Get ComUpdateString Of hoJson "messages[0].metadata.myKey" "myValue" To iSuccess
    Get ComUpdateString Of hoJson "messages[0].metadata.anotherKey" "anotherValue" To iSuccess
    Get ComUpdateString Of hoJson "messages[0].scheduled" "2016-11-03T11:49:02.807Z" To iSuccess
    Get ComUpdateString Of hoJson "messages[0].source_number" "+61491570157" To iSuccess
    Get ComUpdateString Of hoJson "messages[0].source_number_type" "INTERNATIONAL" To iSuccess
    Get ComUpdateString Of hoJson "messages[1].callback_url" "https://my.callback.url.com" To iSuccess
    Get ComUpdateString Of hoJson "messages[1].content" "My second message" To iSuccess
    Get ComUpdateString Of hoJson "messages[1].destination_number" "+61491570158" To iSuccess
    Get ComUpdateBool Of hoJson "messages[1].delivery_report" True To iSuccess
    Get ComUpdateString Of hoJson "messages[1].format" "MMS" To iSuccess
    Get ComUpdateString Of hoJson "messages[1].subject" "This is an MMS message" To iSuccess
    Get ComUpdateString Of hoJson "messages[1].media[0]" "https://images.pexels.com/photos/1018350/pexels-photo-1018350.jpeg?cs=srgb&dl=architecture-buildings-city-1018350.jpg" To iSuccess
    Get ComUpdateString Of hoJson "messages[1].message_expiry_timestamp" "2016-11-03T11:49:02.807Z" To iSuccess
    Get ComUpdateString Of hoJson "messages[1].metadata.myKey" "myValue" To iSuccess
    Get ComUpdateString Of hoJson "messages[1].metadata.anotherKey" "anotherValue" To iSuccess
    Get ComUpdateString Of hoJson "messages[1].scheduled" "2016-11-03T11:49:02.807Z" To iSuccess
    Get ComUpdateString Of hoJson "messages[1].source_number" "+61491570159" To iSuccess
    Get ComUpdateString Of hoJson "messages[1].source_number_type" "INTERNATIONAL" To iSuccess

    Send ComSetRequestHeader To hoHttp "Content-Type" "application/json"
    Send ComSetRequestHeader To hoHttp "Accept" "application/json"

    Get pvComObject of hoJson to vJson
    Get ComPostJson3 Of hoHttp "https://private-anon-ecbaffbc28-messages32.apiary-mock.com/v1/messages" "application/json" vJson 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)

    // {
    //   "messages": [
    //     {
    //       "message_id": "04fe9a97-a579-43c5-bb1a-58ed29bf0a6a",
    //       "callback_url": "https://my.url.com",
    //       "status": "delivered",
    //       "content": "My first message",
    //       "destination_number": "+61491570156",
    //       "delivery_report": true,
    //       "format": "SMS",
    //       "message_expiry_timestamp": "2016-11-03T11:49:02.807Z",
    //       "metadata": {
    //         "myKey": "myValue",
    //         "anotherKey": "anotherValue"
    //       },
    //       "scheduled": "2016-11-03T11:49:02.807Z",
    //       "source_number": "+61491570157",
    //       "source_number_type": "INTERNATIONAL"
    //     }
    //   ]
    // }

    // Sample code for parsing the JSON response...
    // Use the following online tool to generate parsing code from sample JSON:
    // Generate Parsing Code from JSON

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "messages" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "messages[i].message_id" To sMessage_id
        Get ComStringOf Of hoJResp "messages[i].callback_url" To sCallback_url
        Get ComStringOf Of hoJResp "messages[i].status" To sStatus
        Get ComStringOf Of hoJResp "messages[i].content" To sContent
        Get ComStringOf Of hoJResp "messages[i].destination_number" To sDestination_number
        Get ComBoolOf Of hoJResp "messages[i].delivery_report" To iDelivery_report
        Get ComStringOf Of hoJResp "messages[i].format" To sFormat
        Get ComStringOf Of hoJResp "messages[i].message_expiry_timestamp" To sMessage_expiry_timestamp
        Get ComStringOf Of hoJResp "messages[i].metadata.myKey" To sMyKey
        Get ComStringOf Of hoJResp "messages[i].metadata.anotherKey" To sAnotherKey
        Get ComStringOf Of hoJResp "messages[i].scheduled" To sScheduled
        Get ComStringOf Of hoJResp "messages[i].source_number" To sSource_number
        Get ComStringOf Of hoJResp "messages[i].source_number_type" To sSource_number_type
        Move (i + 1) To i
    Loop



End_Procedure

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.