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
Jira
Lightspeed
MYOB
Magento
Mailgun

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
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
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) Twilio Send MMS (using Chilkat HTTP)

Send an outgoing MMS message. The only difference with MMS (as compared with SMS) is that a MediaUrl parameter is added to the POST. This means your image must be accessible on the web -- the Twilio server must be able to download the image from the URL you provide to include it in the MMS mesage to be sent.

Also, see Twilio MMS for more information about MMS.

For more information, see https://support.twilio.com/hc/en-us/articles/223179808-Sending-and-receiving-MMS-messages

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vReq
    Handle hoReq
    Variant vResp
    Handle hoResp
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJResp
    Integer iRespStatusCode
    Variant vDate_created
    Handle hoDate_created
    Variant vDate_updated
    Handle hoDate_updated
    Variant vDate_sent
    Handle hoDate_sent
    String sSid
    String sAccount_sid
    String sV_to
    String sFrom
    String sMessaging_service_sid
    String sBody
    String sStatus
    String sNum_segments
    String sNum_media
    String sDirection
    String sApi_version
    String sPrice
    String sPrice_unit
    String sError_code
    String sError_message
    String sUri
    String sSubresource_urisMedia
    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:

    // (See information about using test credentials and phone numbers:  https://www.twilio.com/docs/iam/test-credentials)

    // curl -X POST https://api.twilio.com/2010-04-01/Accounts/TWILIO_ACCOUNT_SID/Messages.json \
    // --data-urlencode "From=+15005550006" \
    // --data-urlencode "Body=body" \
    // --data-urlencode "To=+15005551212" \
    // -u TWILIO_ACCOUNT_SID:TWILIO_AUTH_TOKEN

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

    Set ComLogin Of hoHttp To "TWILIO_ACCOUNT_SID"
    Set ComPassword Of hoHttp To "TWILIO_AUTH_TOKEN"

    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 "/2010-04-01/Accounts/TWILIO_ACCOUNT_SID/Messages.json"
    Set ComContentType Of hoReq To "application/x-www-form-urlencoded"
    Send ComAddParam To hoReq "From" "+15005550006"
    Send ComAddParam To hoReq "Body" "body"
    Send ComAddParam To hoReq "To" "+15005551212"
    Send ComAddParam To hoReq "MediaUrl" "https://www.chilkatsoft.com/images/starfish.jpg"

    Get pvComObject of hoReq to vReq
    Get ComPostUrlEncoded Of hoHttp "https://api.twilio.com/2010-04-01/Accounts/TWILIO_ACCOUNT_SID/Messages.json" 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

    // A 201 status code indicates success.
    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)

    // {
    //   "sid": "SM477111c301794f14b11eca5eefd5c350",
    //   "date_created": "Tue, 18 Aug 2020 15:04:47 +0000",
    //   "date_updated": "Tue, 18 Aug 2020 15:04:47 +0000",
    //   "date_sent": null,
    //   "account_sid": "AC2e9b6bc0f51133df24926f07341d3824",
    //   "to": "+15005551212",
    //   "from": "+15005550006",
    //   "messaging_service_sid": null,
    //   "body": "body",
    //   "status": "queued",
    //   "num_segments": "1",
    //   "num_media": "0",
    //   "direction": "outbound-api",
    //   "api_version": "2010-04-01",
    //   "price": null,
    //   "price_unit": "USD",
    //   "error_code": null,
    //   "error_message": null,
    //   "uri": "/2010-04-01/Accounts/AC2e9b6bc0f51133df24926f07341d3824/Messages/SM477111c301794f14b11eca5eefd5c350.json",
    //   "subresource_uris": {
    //     "media": "/2010-04-01/Accounts/AC2e9b6bc0f51133df24926f07341d3824/Messages/SM477111c301794f14b11eca5eefd5c350/Media.json"
    //   }
    // }

    // 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 Create (RefClass(cComChilkatDtObj)) To hoDate_created
    If (Not(IsComObjectCreated(hoDate_created))) Begin
        Send CreateComObject of hoDate_created
    End
    Get Create (RefClass(cComChilkatDtObj)) To hoDate_updated
    If (Not(IsComObjectCreated(hoDate_updated))) Begin
        Send CreateComObject of hoDate_updated
    End
    Get Create (RefClass(cComChilkatDtObj)) To hoDate_sent
    If (Not(IsComObjectCreated(hoDate_sent))) Begin
        Send CreateComObject of hoDate_sent
    End

    Get ComStringOf Of hoJResp "sid" To sSid
    Get pvComObject of hoDate_created to vDate_created
    Get ComDtOf Of hoJResp "date_created" False vDate_created To iSuccess
    Get pvComObject of hoDate_updated to vDate_updated
    Get ComDtOf Of hoJResp "date_updated" False vDate_updated To iSuccess
    Get pvComObject of hoDate_sent to vDate_sent
    Get ComDtOf Of hoJResp "date_sent" False vDate_sent To iSuccess
    Get ComStringOf Of hoJResp "account_sid" To sAccount_sid
    Get ComStringOf Of hoJResp "to" To sV_to
    Get ComStringOf Of hoJResp "from" To sFrom
    Get ComStringOf Of hoJResp "messaging_service_sid" To sMessaging_service_sid
    Get ComStringOf Of hoJResp "body" To sBody
    Get ComStringOf Of hoJResp "status" To sStatus
    Get ComStringOf Of hoJResp "num_segments" To sNum_segments
    Get ComStringOf Of hoJResp "num_media" To sNum_media
    Get ComStringOf Of hoJResp "direction" To sDirection
    Get ComStringOf Of hoJResp "api_version" To sApi_version
    Get ComStringOf Of hoJResp "price" To sPrice
    Get ComStringOf Of hoJResp "price_unit" To sPrice_unit
    Get ComStringOf Of hoJResp "error_code" To sError_code
    Get ComStringOf Of hoJResp "error_message" To sError_message
    Get ComStringOf Of hoJResp "uri" To sUri
    Get ComStringOf Of hoJResp "subresource_uris.media" To sSubresource_urisMedia


End_Procedure

 

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