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

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

 

 

 

(Tcl) WordPress Authentication with Applications Password Plugin

See more WordPress Examples

Demonstrates basic username/password authentication using the WordPress Applications Password plugin.

For more information, see https://wordpress.org/plugins/application-passwords/

Chilkat Tcl Extension Downloads

Chilkat Tcl Extension Downloads

load ./chilkat.dll

# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

set http [new_CkHttp]

# Implements the following CURL command:

# curl -X GET --user wp_username:app_password https://www.yoursite.com/wp-json/wp/v2/posts?page=1

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

# Use your WordPress login, such as "admin", not the application name.
CkHttp_put_Login $http "wp_username"
# Use the application password, such as "Nths RwVH eDJ4 weNZ orMN jabq"
CkHttp_put_Password $http "app_password"
CkHttp_put_BasicAuth $http 1

set sbResponseBody [new_CkStringBuilder]

set success [CkHttp_QuickGetSb $http "https://www.yoursite.com/wp-json/wp/v2/posts?page=1" $sbResponseBody]
if {$success == 0} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkHttp $http
    delete_CkStringBuilder $sbResponseBody
    exit
}

set jarrResp [new_CkJsonArray]

CkJsonArray_LoadSb $jarrResp $sbResponseBody
CkJsonArray_put_EmitCompact $jarrResp 0

puts "Response Body:"
puts [CkJsonArray_emit $jarrResp]

set respStatusCode [CkHttp_get_LastStatus $http]
puts "Response Status Code = $respStatusCode"
if {$respStatusCode >= 400} then {
    puts "Response Header:"
    puts [CkHttp_lastHeader $http]
    puts "Failed."
    delete_CkHttp $http
    delete_CkStringBuilder $sbResponseBody
    delete_CkJsonArray $jarrResp
    exit
}

# 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

set date_gmt [new_CkDtObj]

# json is a CkJsonObject

set i 0
set count_i [CkJsonArray_get_Size $jarrResp]
while {$i < $count_i} {
    set json [CkJsonArray_ObjectAt $jarrResp $i]
    set id [CkJsonObject_IntOf $json "id"]
    set date [CkJsonObject_stringOf $json "date"]
    CkJsonObject_DtOf $json "date_gmt" 0 $date_gmt
    set guidRendered [CkJsonObject_stringOf $json "guid.rendered"]
    set modified [CkJsonObject_stringOf $json "modified"]
    set modified_gmt [CkJsonObject_stringOf $json "modified_gmt"]
    set slug [CkJsonObject_stringOf $json "slug"]
    set status [CkJsonObject_stringOf $json "status"]
    set v_type [CkJsonObject_stringOf $json "type"]
    set link [CkJsonObject_stringOf $json "link"]
    set titleRendered [CkJsonObject_stringOf $json "title.rendered"]
    set contentRendered [CkJsonObject_stringOf $json "content.rendered"]
    set contentProtected [CkJsonObject_BoolOf $json "content.protected"]
    set excerptRendered [CkJsonObject_stringOf $json "excerpt.rendered"]
    set excerptProtected [CkJsonObject_BoolOf $json "excerpt.protected"]
    set author [CkJsonObject_IntOf $json "author"]
    set featured_media [CkJsonObject_IntOf $json "featured_media"]
    set comment_status [CkJsonObject_stringOf $json "comment_status"]
    set ping_status [CkJsonObject_stringOf $json "ping_status"]
    set sticky [CkJsonObject_BoolOf $json "sticky"]
    set template [CkJsonObject_stringOf $json "template"]
    set format [CkJsonObject_stringOf $json "format"]
    set j 0
    set count_j [CkJsonObject_SizeOfArray $json "meta"]
    while {$j < $count_j} {
        CkJsonObject_put_J $json $j
        set j [expr $j + 1]
    }
    set j 0
    set count_j [CkJsonObject_SizeOfArray $json "categories"]
    while {$j < $count_j} {
        CkJsonObject_put_J $json $j
        set intVal [CkJsonObject_IntOf $json "categories[j]"]
        set j [expr $j + 1]
    }
    set j 0
    set count_j [CkJsonObject_SizeOfArray $json "tags"]
    while {$j < $count_j} {
        CkJsonObject_put_J $json $j
        set intVal [CkJsonObject_IntOf $json "tags[j]"]
        set j [expr $j + 1]
    }
    set j 0
    set count_j [CkJsonObject_SizeOfArray $json "_links.self"]
    while {$j < $count_j} {
        CkJsonObject_put_J $json $j
        set href [CkJsonObject_stringOf $json "_links.self[j].href"]
        set j [expr $j + 1]
    }
    set j 0
    set count_j [CkJsonObject_SizeOfArray $json "_links.collection"]
    while {$j < $count_j} {
        CkJsonObject_put_J $json $j
        set href [CkJsonObject_stringOf $json "_links.collection[j].href"]
        set j [expr $j + 1]
    }
    set j 0
    set count_j [CkJsonObject_SizeOfArray $json "_links.about"]
    while {$j < $count_j} {
        CkJsonObject_put_J $json $j
        set href [CkJsonObject_stringOf $json "_links.about[j].href"]
        set j [expr $j + 1]
    }
    set j 0
    set count_j [CkJsonObject_SizeOfArray $json "_links.author"]
    while {$j < $count_j} {
        CkJsonObject_put_J $json $j
        set embeddable [CkJsonObject_BoolOf $json "_links.author[j].embeddable"]
        set href [CkJsonObject_stringOf $json "_links.author[j].href"]
        set j [expr $j + 1]
    }
    set j 0
    set count_j [CkJsonObject_SizeOfArray $json "_links.replies"]
    while {$j < $count_j} {
        CkJsonObject_put_J $json $j
        set embeddable [CkJsonObject_BoolOf $json "_links.replies[j].embeddable"]
        set href [CkJsonObject_stringOf $json "_links.replies[j].href"]
        set j [expr $j + 1]
    }
    set j 0
    set count_j [CkJsonObject_SizeOfArray $json "_links.version-history"]
    while {$j < $count_j} {
        CkJsonObject_put_J $json $j
        set count [CkJsonObject_IntOf $json "_links.version-history[j].count"]
        set href [CkJsonObject_stringOf $json "_links.version-history[j].href"]
        set j [expr $j + 1]
    }
    set j 0
    set count_j [CkJsonObject_SizeOfArray $json "_links.predecessor-version"]
    while {$j < $count_j} {
        CkJsonObject_put_J $json $j
        set id [CkJsonObject_IntOf $json "_links.predecessor-version[j].id"]
        set href [CkJsonObject_stringOf $json "_links.predecessor-version[j].href"]
        set j [expr $j + 1]
    }
    set j 0
    set count_j [CkJsonObject_SizeOfArray $json "_links.wp:attachment"]
    while {$j < $count_j} {
        CkJsonObject_put_J $json $j
        set href [CkJsonObject_stringOf $json "_links.wp:attachment[j].href"]
        set j [expr $j + 1]
    }
    set j 0
    set count_j [CkJsonObject_SizeOfArray $json "_links.wp:term"]
    while {$j < $count_j} {
        CkJsonObject_put_J $json $j
        set taxonomy [CkJsonObject_stringOf $json "_links.wp:term[j].taxonomy"]
        set embeddable [CkJsonObject_BoolOf $json "_links.wp:term[j].embeddable"]
        set href [CkJsonObject_stringOf $json "_links.wp:term[j].href"]
        set j [expr $j + 1]
    }
    set j 0
    set count_j [CkJsonObject_SizeOfArray $json "_links.curies"]
    while {$j < $count_j} {
        CkJsonObject_put_J $json $j
        set name [CkJsonObject_stringOf $json "_links.curies[j].name"]
        set href [CkJsonObject_stringOf $json "_links.curies[j].href"]
        set templated [CkJsonObject_BoolOf $json "_links.curies[j].templated"]
        set j [expr $j + 1]
    }
    delete_CkJsonObject $json

    set i [expr $i + 1]
}

delete_CkHttp $http
delete_CkStringBuilder $sbResponseBody
delete_CkJsonArray $jarrResp
delete_CkDtObj $date_gmt

 

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