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

 

 

 

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

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_Cipher
string ls_Code_str
string ls_Id
string ls_Name
string ls_Region
string ls_Seller_type
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
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.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
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_JsonToken.ConnectToNewObject("Chilkat.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

loo_QueryParams = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_QueryParams.ConnectToNewObject("Chilkat.JsonObject")

loo_QueryParams.UpdateString("app_key","APP_KEY")
loo_Dt = create oleobject
// Use "Chilkat_9_5_0.CkDateTime" for versions of Chilkat < 10.0.0
li_rc = loo_Dt.ConnectToNewObject("Chilkat.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 = "/authorization/202309/shops"

// Build the StringToSign
loo_Sb = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_Sb.ConnectToNewObject("Chilkat.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
// Use "Chilkat_9_5_0.Crypt2" for versions of Chilkat < 10.0.0
li_rc = loo_Crypt.ConnectToNewObject("Chilkat.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/authorization/202309/shops",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
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")

loo_Resp.GetBodyJson(loo_Json)

Write-Debug string(loo_Resp.StatusCode)
Write-Debug loo_Resp.BodyStr
destroy loo_Resp

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

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.shops")
do while i < li_Count_i
    loo_Json.I = i
    ls_Cipher = loo_Json.StringOf("data.shops[i].cipher")
    ls_Code_str = loo_Json.StringOf("data.shops[i].code")
    ls_Id = loo_Json.StringOf("data.shops[i].id")
    ls_Name = loo_Json.StringOf("data.shops[i].name")
    ls_Region = loo_Json.StringOf("data.shops[i].region")
    ls_Seller_type = loo_Json.StringOf("data.shops[i].seller_type")
    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.