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) WordPress API Key Authentication with miniOrange Plugin

See more WordPress Examples

Demonstrates API key authentication using the miniOrange API Authentication plugin.

For more information, see https://wordpress.org/plugins/wp-rest-api-authentication/

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJarrResp
    Integer iRespStatusCode
    Variant vDate_gmt
    Handle hoDate_gmt
    Variant vJson
    Handle hoJson
    Integer iId
    String sDate
    String sGuidRendered
    String sModified
    String sModified_gmt
    String sSlug
    String sStatus
    String sV_type
    String sLink
    String sTitleRendered
    String sContentRendered
    Boolean iContentProtected
    String sExcerptRendered
    Boolean iExcerptProtected
    Integer iAuthor
    Integer iFeatured_media
    String sComment_status
    String sPing_status
    Boolean iSticky
    String sTemplate
    String sFormat
    Integer j
    Integer iCount_j
    Integer iIntVal
    String sHref
    Boolean iEmbeddable
    Integer iCount
    String sTaxonomy
    String sName
    Boolean iTemplated
    Integer i
    Integer iCount_i
    String sTemp1

    // 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

    // Use your API key here, such as TaVFjSBu8IMR0MbvZNn7A6P04GXrbtHm
    // This causes the "Authorization: Bearer <api_key>" header to be added to each HTTP request.
    Set ComAuthToken Of hoHttp To "api_key"

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComQuickGetSb Of hoHttp "https://www.yoursite.com/wp-json/wp/v2/posts?page=1" vSbResponseBody To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatJsonArray)) To hoJarrResp
    If (Not(IsComObjectCreated(hoJarrResp))) Begin
        Send CreateComObject of hoJarrResp
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJarrResp vSbResponseBody To iSuccess
    Set ComEmitCompact Of hoJarrResp To False

    Showln "Response Body:"
    Get ComEmit Of hoJarrResp To sTemp1
    Showln sTemp1

    Get ComLastStatus Of hoHttp To iRespStatusCode
    Showln "Response Status Code = " iRespStatusCode
    If (iRespStatusCode >= 400) Begin
        Showln "Response Header:"
        Get ComLastHeader Of hoHttp To sTemp1
        Showln sTemp1
        Showln "Failed."
        Procedure_Return
    End

    // Sample JSON response:
    // (Sample code for parsing the JSON response is shown below)

    // [
    //   {
    //     "id": 1902,
    //     "date": "2020-11-16T09:54:09",
    //     "date_gmt": "2020-11-16T16:54:09",
    //     "guid": {
    //       "rendered": "http:\/\/cknotes.com\/?p=1902"
    //     },
    //     "modified": "2020-11-16T09:54:09",
    //     "modified_gmt": "2020-11-16T16:54:09",
    //     "slug": "xero-redirect-uri-for-oauth2-and-desktop-apps",
    //     "status": "publish",
    //     "type": "post",
    //     "link": "https:\/\/cknotes.com\/xero-redirect-uri-for-oauth2-and-desktop-apps\/",
    //     "title": {
    //       "rendered": "Xero Redirect URI for OAuth2 and Desktop Apps"
    //     },
    //     "content": {
    //       "rendered": "<p>...",
    //       "protected": false
    //     },
    //     "excerpt": {
    //       "rendered": "<p>...",
    //       "protected": false
    //     },
    //     "author": 1,
    //     "featured_media": 0,
    //     "comment_status": "closed",
    //     "ping_status": "open",
    //     "sticky": false,
    //     "template": "",
    //     "format": "standard",
    //     "meta": [
    //     ],
    //     "categories": [
    //       815
    //     ],
    //     "tags": [
    //       594,
    //       816
    //     ],
    //     "_links": {
    //       "self": [
    //         {
    //           "href": "https:\/\/cknotes.com\/wp-json\/wp\/v2\/posts\/1902"
    //         }
    //       ],
    //       "collection": [
    //         {
    //           "href": "https:\/\/cknotes.com\/wp-json\/wp\/v2\/posts"
    //         }
    //       ],
    //       "about": [
    //         {
    //           "href": "https:\/\/cknotes.com\/wp-json\/wp\/v2\/types\/post"
    //         }
    //       ],
    //       "author": [
    //         {
    //           "embeddable": true,
    //           "href": "https:\/\/cknotes.com\/wp-json\/wp\/v2\/users\/1"
    //         }
    //       ],
    //       "replies": [
    //         {
    //           "embeddable": true,
    //           "href": "https:\/\/cknotes.com\/wp-json\/wp\/v2\/comments?post=1902"
    //         }
    //       ],
    //       "version-history": [
    //         {
    //           "count": 1,
    //           "href": "https:\/\/cknotes.com\/wp-json\/wp\/v2\/posts\/1902\/revisions"
    //         }
    //       ],
    //       "predecessor-version": [
    //         {
    //           "id": 1904,
    //           "href": "https:\/\/cknotes.com\/wp-json\/wp\/v2\/posts\/1902\/revisions\/1904"
    //         }
    //       ],
    //       "wp:attachment": [
    //         {
    //           "href": "https:\/\/cknotes.com\/wp-json\/wp\/v2\/media?parent=1902"
    //         }
    //       ],
    //       "wp:term": [
    //         {
    //           "taxonomy": "category",
    //           "embeddable": true,
    //           "href": "https:\/\/cknotes.com\/wp-json\/wp\/v2\/categories?post=1902"
    //         },
    //         {
    //           "taxonomy": "post_tag",
    //           "embeddable": true,
    //           "href": "https:\/\/cknotes.com\/wp-json\/wp\/v2\/tags?post=1902"
    //         }
    //       ],
    //       "curies": [
    //         {
    //           "name": "wp",
    //           "href": "https:\/\/api.w.org\/{rel}",
    //           "templated": true
    //         }
    //       ]
    //     }
    //   },
    // ...
    // ]

    // 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_gmt
    If (Not(IsComObjectCreated(hoDate_gmt))) Begin
        Send CreateComObject of hoDate_gmt
    End

    Move 0 To i
    Get ComSize Of hoJarrResp To iCount_i
    While (i < iCount_i)
        Get ComObjectAt Of hoJarrResp i To vJson
        If (IsComObject(vJson)) Begin
            Get Create (RefClass(cComChilkatJsonObject)) To hoJson
            Set pvComObject Of hoJson To vJson
        End
        Get ComIntOf Of hoJson "id" To iId
        Get ComStringOf Of hoJson "date" To sDate
        Get pvComObject of hoDate_gmt to vDate_gmt
        Get ComDtOf Of hoJson "date_gmt" False vDate_gmt To iSuccess
        Get ComStringOf Of hoJson "guid.rendered" To sGuidRendered
        Get ComStringOf Of hoJson "modified" To sModified
        Get ComStringOf Of hoJson "modified_gmt" To sModified_gmt
        Get ComStringOf Of hoJson "slug" To sSlug
        Get ComStringOf Of hoJson "status" To sStatus
        Get ComStringOf Of hoJson "type" To sV_type
        Get ComStringOf Of hoJson "link" To sLink
        Get ComStringOf Of hoJson "title.rendered" To sTitleRendered
        Get ComStringOf Of hoJson "content.rendered" To sContentRendered
        Get ComBoolOf Of hoJson "content.protected" To iContentProtected
        Get ComStringOf Of hoJson "excerpt.rendered" To sExcerptRendered
        Get ComBoolOf Of hoJson "excerpt.protected" To iExcerptProtected
        Get ComIntOf Of hoJson "author" To iAuthor
        Get ComIntOf Of hoJson "featured_media" To iFeatured_media
        Get ComStringOf Of hoJson "comment_status" To sComment_status
        Get ComStringOf Of hoJson "ping_status" To sPing_status
        Get ComBoolOf Of hoJson "sticky" To iSticky
        Get ComStringOf Of hoJson "template" To sTemplate
        Get ComStringOf Of hoJson "format" To sFormat
        Move 0 To j
        Get ComSizeOfArray Of hoJson "meta" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJson To j
            Move (j + 1) To j
        Loop

        Move 0 To j
        Get ComSizeOfArray Of hoJson "categories" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJson To j
            Get ComIntOf Of hoJson "categories[j]" To iIntVal
            Move (j + 1) To j
        Loop

        Move 0 To j
        Get ComSizeOfArray Of hoJson "tags" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJson To j
            Get ComIntOf Of hoJson "tags[j]" To iIntVal
            Move (j + 1) To j
        Loop

        Move 0 To j
        Get ComSizeOfArray Of hoJson "_links.self" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJson To j
            Get ComStringOf Of hoJson "_links.self[j].href" To sHref
            Move (j + 1) To j
        Loop

        Move 0 To j
        Get ComSizeOfArray Of hoJson "_links.collection" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJson To j
            Get ComStringOf Of hoJson "_links.collection[j].href" To sHref
            Move (j + 1) To j
        Loop

        Move 0 To j
        Get ComSizeOfArray Of hoJson "_links.about" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJson To j
            Get ComStringOf Of hoJson "_links.about[j].href" To sHref
            Move (j + 1) To j
        Loop

        Move 0 To j
        Get ComSizeOfArray Of hoJson "_links.author" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJson To j
            Get ComBoolOf Of hoJson "_links.author[j].embeddable" To iEmbeddable
            Get ComStringOf Of hoJson "_links.author[j].href" To sHref
            Move (j + 1) To j
        Loop

        Move 0 To j
        Get ComSizeOfArray Of hoJson "_links.replies" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJson To j
            Get ComBoolOf Of hoJson "_links.replies[j].embeddable" To iEmbeddable
            Get ComStringOf Of hoJson "_links.replies[j].href" To sHref
            Move (j + 1) To j
        Loop

        Move 0 To j
        Get ComSizeOfArray Of hoJson "_links.version-history" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJson To j
            Get ComIntOf Of hoJson "_links.version-history[j].count" To iCount
            Get ComStringOf Of hoJson "_links.version-history[j].href" To sHref
            Move (j + 1) To j
        Loop

        Move 0 To j
        Get ComSizeOfArray Of hoJson "_links.predecessor-version" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJson To j
            Get ComIntOf Of hoJson "_links.predecessor-version[j].id" To iId
            Get ComStringOf Of hoJson "_links.predecessor-version[j].href" To sHref
            Move (j + 1) To j
        Loop

        Move 0 To j
        Get ComSizeOfArray Of hoJson "_links.wp:attachment" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJson To j
            Get ComStringOf Of hoJson "_links.wp:attachment[j].href" To sHref
            Move (j + 1) To j
        Loop

        Move 0 To j
        Get ComSizeOfArray Of hoJson "_links.wp:term" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJson To j
            Get ComStringOf Of hoJson "_links.wp:term[j].taxonomy" To sTaxonomy
            Get ComBoolOf Of hoJson "_links.wp:term[j].embeddable" To iEmbeddable
            Get ComStringOf Of hoJson "_links.wp:term[j].href" To sHref
            Move (j + 1) To j
        Loop

        Move 0 To j
        Get ComSizeOfArray Of hoJson "_links.curies" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJson To j
            Get ComStringOf Of hoJson "_links.curies[j].name" To sName
            Get ComStringOf Of hoJson "_links.curies[j].href" To sHref
            Get ComBoolOf Of hoJson "_links.curies[j].templated" To iTemplated
            Move (j + 1) To j
        Loop

        Send Destroy of hoJson
        Move (i + 1) To i
    Loop



End_Procedure

 

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