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

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

 

 

 

(PowerBuilder) 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

integer li_rc
oleobject loo_Http
oleobject loo_JsonToken
integer li_Success
oleobject loo_QueryParams
oleobject loo_Dt
integer li_Ascending
integer li_CaseSensitive
string ls_AppSecret
string ls_Path
oleobject loo_Sb
integer li_NumParams
integer i
oleobject loo_Crypt
string ls_Sig
oleobject loo_Resp
oleobject loo_Json
string ls_Id
integer li_Is_leaf
string ls_Local_name
string ls_Parent_id
integer j
integer li_Count_j
string ls_StrVal
integer li_Code
string ls_Message
string ls_Request_id
integer li_Count_i

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

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat_9_5_0.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

// 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
loo_JsonToken = create oleobject
li_rc = loo_JsonToken.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

li_Success = loo_JsonToken.LoadFile("qa_data/tokens/tiktok-shops.json")
if li_Success <> 1 then
    Write-Debug "Failed to load tiktok-shops.json"
    destroy loo_Http
    destroy loo_JsonToken
    return
end if

// Replace values in all caps with your specific values.
// SHOP_CIPHER and SHOP_ID are returned from this example: Get Authorized Shops
loo_QueryParams = create oleobject
li_rc = loo_QueryParams.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_QueryParams.UpdateString("app_key","APP_KEY")
loo_QueryParams.UpdateString("shop_cipher","SHOP_CIPHER")
loo_QueryParams.UpdateString("shop_id","SHOP_ID")
loo_Dt = create oleobject
li_rc = loo_Dt.ConnectToNewObject("Chilkat_9_5_0.CkDateTime")

loo_QueryParams.UpdateString("timestamp",loo_Dt.GetAsUnixTimeStr(0))
loo_QueryParams.UpdateInt("version",202309)

// 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
li_Ascending = 1
li_CaseSensitive = 1
loo_QueryParams.Sort(li_Ascending,li_CaseSensitive)

ls_AppSecret = "APP_SECRET"
ls_Path = "/product/202309/categories"

// Build the StringToSign
loo_Sb = create oleobject
li_rc = loo_Sb.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

loo_Sb.Append(ls_AppSecret)
loo_Sb.Append(ls_Path)
li_NumParams = loo_QueryParams.Size
i = 0
do while i < li_NumParams
    loo_Sb.Append(loo_QueryParams.NameAt(i))
    loo_Sb.Append(loo_QueryParams.StringAt(i))
    i = i + 1
loop
loo_Sb.Append(ls_AppSecret)

loo_Crypt = create oleobject
li_rc = loo_Crypt.ConnectToNewObject("Chilkat_9_5_0.Crypt2")

loo_Crypt.HashAlgorithm = "SHA256"
loo_Crypt.MacAlgorithm = "HMAC"
loo_Crypt.EncodingMode = "hex_lower"
loo_Crypt.SetMacKeyString(ls_AppSecret)

ls_Sig = loo_Crypt.MacStringENC(loo_Sb.GetAsString())

loo_QueryParams.UpdateString("access_token",loo_JsonToken.StringOf("data.access_token"))
loo_QueryParams.UpdateString("sign",ls_Sig)

loo_Http.SetRequestHeader("x-tts-access-token",loo_JsonToken.StringOf("data.access_token"))
loo_Http.SetRequestHeader("content-type","application/json")

loo_Resp = loo_Http.QuickRequestParams("GET","https://open-api.tiktokglobalshop.com/product/202309/categories",loo_QueryParams)
if loo_Http.LastMethodSuccess = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_JsonToken
    destroy loo_QueryParams
    destroy loo_Dt
    destroy loo_Sb
    destroy loo_Crypt
    return
end if

loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_Resp.GetBodyJson(loo_Json)

Write-Debug string(loo_Resp.StatusCode)
destroy loo_Resp

li_Code = loo_Json.IntOf("code")
ls_Message = loo_Json.StringOf("message")
ls_Request_id = loo_Json.StringOf("request_id")
i = 0
li_Count_i = loo_Json.SizeOfArray("data.categories")
do while i < li_Count_i
    loo_Json.I = i
    ls_Id = loo_Json.StringOf("data.categories[i].id")
    li_Is_leaf = loo_Json.BoolOf("data.categories[i].is_leaf")
    ls_Local_name = loo_Json.StringOf("data.categories[i].local_name")
    Write-Debug "local_name: " + ls_Local_name
    ls_Parent_id = loo_Json.StringOf("data.categories[i].parent_id")
    j = 0
    li_Count_j = loo_Json.SizeOfArray("data.categories[i].permission_statuses")
    do while j < li_Count_j
        loo_Json.J = j
        ls_StrVal = loo_Json.StringOf("data.categories[i].permission_statuses[j]")
        j = j + 1
    loop
    i = i + 1
loop


destroy loo_Http
destroy loo_JsonToken
destroy loo_QueryParams
destroy loo_Dt
destroy loo_Sb
destroy loo_Crypt
destroy loo_Json

 

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