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 Authorized Shops

See more TikTok Shop Examples

An example showing how to get the authorized shops in the TikTok Shops API.

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.

For more information, see https://partner.tiktokshop.com/docv2/page/6507ead7b99d5302be949ba9?external_id=6507ead7b99d5302be949ba9

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 sCipher
    String sCode_str
    String sId
    String sName
    String sRegion
    String sSeller_type
    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

    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 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 "/authorization/202309/shops" 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/authorization/202309/shops" 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
    Get ComBodyStr Of hoResp To sTemp1
    Showln sTemp1
    Send Destroy of hoResp

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

    // {
    //   "code": 0,
    //   "data": {
    //     "shops": [
    //       {
    //         "cipher": "GCP_XF90igAAAABh00qsWgtvOiGFNqyubMt3",
    //         "code": "CNGBCBA4LLU8",
    //         "id": "7000714532876273420",
    //         "name": "Maomao beauty shop",
    //         "region": "GB",
    //         "seller_type": "CROSS_BORDER"
    //       }
    //     ]
    //   },
    //   "message": "Success",
    //   "request_id": "202203070749000101890810281E8C70B7"
    // }

    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.shops" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJson To i
        Get ComStringOf Of hoJson "data.shops[i].cipher" To sCipher
        Get ComStringOf Of hoJson "data.shops[i].code" To sCode_str
        Get ComStringOf Of hoJson "data.shops[i].id" To sId
        Get ComStringOf Of hoJson "data.shops[i].name" To sName
        Get ComStringOf Of hoJson "data.shops[i].region" To sRegion
        Get ComStringOf Of hoJson "data.shops[i].seller_type" To sSeller_type
        Move (i + 1) To i
    Loop



End_Procedure

 

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