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) TikTok Shop Get Categories

See more TikTok Shop Examples

An example showing how to use a TikTok Shops access token in an API call.

IMPORTANT: This example requires a pre-release for the next version of Chilkat after the current v9.5.0.99 release. Contact info@chilkatsoft.com if you wish to get a pre-release. However, pre-releases of .NET Core (hosted on NuGet) and Node.js will not be possible.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoHttp
    Handle hoJsonToken
    Boolean iSuccess
    Variant vQueryParams
    Handle hoQueryParams
    Handle hoDt
    Boolean iAscending
    Boolean iCaseSensitive
    String sAppSecret
    String sPath
    Handle hoSb
    Integer iNumParams
    Integer i
    Handle hoCrypt
    String sSig
    Variant vResp
    Handle hoResp
    Variant vJson
    Handle hoJson
    String sId
    Boolean iIs_leaf
    String sLocal_name
    String sParent_id
    Integer j
    Integer iCount_j
    String sStrVal
    Integer iCode
    String sMessage
    String sRequest_id
    Integer iCount_i
    String sTemp1
    Integer iTemp1
    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

    // It is assumed we previously obtained an OAuth2 access token.
    // This example loads the JSON access token file 
    // saved by this example: Get TikTok Shop OAuth2 Access Token
    // or refrehsed by this example: Get TikTok Shop Refresh OAuth2 Access Token
    Get Create (RefClass(cComChilkatJsonObject)) To hoJsonToken
    If (Not(IsComObjectCreated(hoJsonToken))) Begin
        Send CreateComObject of hoJsonToken
    End
    Get ComLoadFile Of hoJsonToken "qa_data/tokens/tiktok-shops.json" To iSuccess
    If (iSuccess <> True) Begin
        Showln "Failed to load tiktok-shops.json"
        Procedure_Return
    End

    // Replace values in all caps with your specific values.
    // SHOP_CIPHER and SHOP_ID are returned from this example: Get Authorized Shops
    Get Create (RefClass(cComChilkatJsonObject)) To hoQueryParams
    If (Not(IsComObjectCreated(hoQueryParams))) Begin
        Send CreateComObject of hoQueryParams
    End
    Get ComUpdateString Of hoQueryParams "app_key" "APP_KEY" To iSuccess
    Get ComUpdateString Of hoQueryParams "shop_cipher" "SHOP_CIPHER" To iSuccess
    Get ComUpdateString Of hoQueryParams "shop_id" "SHOP_ID" To iSuccess
    Get Create (RefClass(cComCkDateTime)) To hoDt
    If (Not(IsComObjectCreated(hoDt))) Begin
        Send CreateComObject of hoDt
    End
    Get ComGetAsUnixTimeStr Of hoDt False To sTemp1
    Get ComUpdateString Of hoQueryParams "timestamp" sTemp1 To iSuccess
    Get ComUpdateInt Of hoQueryParams "version" 202309 To iSuccess

    // Sort the JSON members by member name, in ascending order (A-Z), case sensitive..
    // Note: The Sort method is added in Chilkat v9.5.0.100
    Move True To iAscending
    Move True To iCaseSensitive
    Send ComSort To hoQueryParams iAscending iCaseSensitive

    Move "APP_SECRET" To sAppSecret
    Move "/product/202309/categories" To sPath

    // Build the StringToSign
    Get Create (RefClass(cComChilkatStringBuilder)) To hoSb
    If (Not(IsComObjectCreated(hoSb))) Begin
        Send CreateComObject of hoSb
    End
    Get ComAppend Of hoSb sAppSecret To iSuccess
    Get ComAppend Of hoSb sPath To iSuccess
    Get ComSize Of hoQueryParams To iNumParams
    Move 0 To i
    While (i < iNumParams)
        Get ComNameAt Of hoQueryParams i To sTemp1
        Get ComAppend Of hoSb sTemp1 To iSuccess
        Get ComStringAt Of hoQueryParams i To sTemp1
        Get ComAppend Of hoSb sTemp1 To iSuccess
        Move (i + 1) To i
    Loop

    Get ComAppend Of hoSb sAppSecret To iSuccess

    Get Create (RefClass(cComChilkatCrypt2)) To hoCrypt
    If (Not(IsComObjectCreated(hoCrypt))) Begin
        Send CreateComObject of hoCrypt
    End
    Set ComHashAlgorithm Of hoCrypt To "SHA256"
    Set ComMacAlgorithm Of hoCrypt To "HMAC"
    Set ComEncodingMode Of hoCrypt To "hex_lower"
    Get ComSetMacKeyString Of hoCrypt sAppSecret To iSuccess

    Get ComGetAsString Of hoSb To sTemp1
    Get ComMacStringENC Of hoCrypt sTemp1 To sSig

    Get ComStringOf Of hoJsonToken "data.access_token" To sTemp1
    Get ComUpdateString Of hoQueryParams "access_token" sTemp1 To iSuccess
    Get ComUpdateString Of hoQueryParams "sign" sSig To iSuccess

    Get ComStringOf Of hoJsonToken "data.access_token" To sTemp1
    Send ComSetRequestHeader To hoHttp "x-tts-access-token" sTemp1
    Send ComSetRequestHeader To hoHttp "content-type" "application/json"

    Get pvComObject of hoQueryParams to vQueryParams
    Get ComQuickRequestParams Of hoHttp "GET" "https://open-api.tiktokglobalshop.com/product/202309/categories" vQueryParams 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(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get pvComObject of hoJson to vJson
    Get ComGetBodyJson Of hoResp vJson To iSuccess

    Get ComStatusCode Of hoResp To iTemp1
    Showln iTemp1
    Send Destroy of hoResp

    Get ComIntOf Of hoJson "code" To iCode
    Get ComStringOf Of hoJson "message" To sMessage
    Get ComStringOf Of hoJson "request_id" To sRequest_id
    Move 0 To i
    Get ComSizeOfArray Of hoJson "data.categories" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJson To i
        Get ComStringOf Of hoJson "data.categories[i].id" To sId
        Get ComBoolOf Of hoJson "data.categories[i].is_leaf" To iIs_leaf
        Get ComStringOf Of hoJson "data.categories[i].local_name" To sLocal_name
        Showln "local_name: " sLocal_name
        Get ComStringOf Of hoJson "data.categories[i].parent_id" To sParent_id
        Move 0 To j
        Get ComSizeOfArray Of hoJson "data.categories[i].permission_statuses" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJson To j
            Get ComStringOf Of hoJson "data.categories[i].permission_statuses[j]" To sStrVal
            Move (j + 1) To j
        Loop

        Move (i + 1) To i
    Loop



End_Procedure

 

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