Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Tcl) Lightspeed - Get All ProductsRetrieve a list of all product objects from this shop. For more information, see https://developers.lightspeedhq.com/ecom/endpoints/product/#get-all-products
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 https://api.shoplightspeed.com/en/products.json \ # -u {key}:{secret} # Use the following online tool to generate HTTP code from a CURL command # Convert a cURL Command to HTTP Source Code CkHttp_put_Login $http "API_KEY" CkHttp_put_Password $http "API_SECRET" # Use the correct cluster for your shop. Here are the choices: # eu1 https://api.webshopapp.com/en/ # us1 https://api.shoplightspeed.com/en/ set sbResponseBody [new_CkStringBuilder] set success [CkHttp_QuickGetSb $http "https://api.webshopapp.com/en/products.json" $sbResponseBody] if {$success == 0} then { puts [CkHttp_lastErrorText $http] delete_CkHttp $http delete_CkStringBuilder $sbResponseBody exit } set jResp [new_CkJsonObject] CkJsonObject_LoadSb $jResp $sbResponseBody CkJsonObject_put_EmitCompact $jResp 0 puts "Response Body:" puts [CkJsonObject_emit $jResp] 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_CkJsonObject $jResp exit } # Sample JSON response: # (Sample code for parsing the JSON response is shown below) # { # "product": { # "id": 20967267, # "createdAt": "2019-05-28T15:25:46+00:00", # "updatedAt": "2019-05-28T17:16:16+00:00", # "isVisible": true, # "visibility": "visible", # "hasMatrix": false, # "data01": "", # "data02": "", # "data03": "", # "url": "lookin-sharp-tee", # "title": "Lookin' Sharp T-Shirt", # "fulltitle": "Lookin' Sharp T-Shirt", # "description": "Description of the Lookin' Sharp T-Shirt", # "content": "<p>Long Description of the Lookin' Sharp T-Shirt</p>", # "set": { # "id": 2785, # "createdAt": "2019-05-28T15:32:12+00:00", # "updatedAt": "2019-05-28T15:42:59+00:00", # "name": "Shirts", # "options": [ # { # "id": 4626, # "sortOrder": 1, # "name": "Size", # "values": [ # { # "id": 14045, # "sortOrder": 1, # "name": "S" # }, # { # "id": 14046, # "sortOrder": 2, # "name": "M" # }, # { # "id": 14047, # "sortOrder": 3, # "name": "L" # } # ] # } # ] # }, # "brand": { # "resource": { # "id": 1171202, # "url": "brands/1171202", # "link": "https://api.shoplightspeed.com/us/brands/1171202.json" # } # }, # "categories": { # "resource": { # "id": false, # "url": "categories/products?product=20967267", # "link": "https://api.shoplightspeed.com/us/categories/products.json?product=20967267" # } # }, # "deliverydate": { # "resource": { # "id": 6488, # "url": "deliverydates/6488", # "link": "https://api.shoplightspeed.com/us/deliverydates/6488.json" # } # }, # "image": { # "createdAt": "2019-05-28T15:25:46+00:00", # "updatedAt": "2019-05-28T15:25:46+00:00", # "extension": "jpg", # "size": 86649, # "title": "17x35x-jcfk-88na-udwd-5hck-z63u-img-16-e0aa4f57-f4", # "thumb": "https://cdn.shoplightspeed.com/shops/000001/files/14119398/50x50x2/17x35x-jcfk-88na-udwd-5hck-z63u-img-16-e0aa4f57-f4.jpg", # "src": "https://cdn.shoplightspeed.com/shops/000001/files/14119398/17x35x-jcfk-88na-udwd-5hck-z63u-img-16-e0aa4f57-f4.jpg" # }, # "images": { # "resource": { # "id": false, # "url": "products/20967267/images", # "link": "https://api.shoplightspeed.com/us/products/20967267/images.json" # } # }, # "relations": { # "resource": { # "id": false, # "url": "products/20967267/relations", # "link": "https://api.shoplightspeed.com/us/products/20967267/relations.json" # } # }, # "metafields": { # "resource": { # "id": false, # "url": "products/20967267/metafields", # "link": "https://api.shoplightspeed.com/us/products/20967267/metafields.json" # } # }, # "reviews": { # "resource": { # "id": false, # "url": "reviews?product=20967267", # "link": "https://api.shoplightspeed.com/us/reviews.json?product=20967267" # } # }, # "type": false, # "attributes": { # "resource": { # "id": false, # "url": "products/20967267/attributes", # "link": "https://api.shoplightspeed.com/us/products/20967267/attributes.json" # } # }, # "supplier": { # "resource": { # "id": 78794, # "url": "suppliers/78794", # "link": "https://api.shoplightspeed.com/us/suppliers/78794.json" # } # }, # "tags": { # "resource": { # "id": false, # "url": "tags/products?product=20967267", # "link": "https://api.shoplightspeed.com/us/tags/products.json?product=20967267" # } # }, # "variants": { # "resource": { # "id": false, # "url": "variants?product=20967267", # "link": "https://api.shoplightspeed.com/us/variants.json?product=20967267" # } # }, # "movements": { # "resource": { # "id": false, # "url": "variants/movements?product=20967267", # "link": "https://api.shoplightspeed.com/us/variants/movements.json?product=20967267" # } # } # } # } # 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 productId [CkJsonObject_IntOf $jResp "product.id"] set productCreatedAt [CkJsonObject_stringOf $jResp "product.createdAt"] set productUpdatedAt [CkJsonObject_stringOf $jResp "product.updatedAt"] set productIsVisible [CkJsonObject_BoolOf $jResp "product.isVisible"] set productVisibility [CkJsonObject_stringOf $jResp "product.visibility"] set productHasMatrix [CkJsonObject_BoolOf $jResp "product.hasMatrix"] set productData01 [CkJsonObject_stringOf $jResp "product.data01"] set productData02 [CkJsonObject_stringOf $jResp "product.data02"] set productData03 [CkJsonObject_stringOf $jResp "product.data03"] set productUrl [CkJsonObject_stringOf $jResp "product.url"] set productTitle [CkJsonObject_stringOf $jResp "product.title"] set productFulltitle [CkJsonObject_stringOf $jResp "product.fulltitle"] set productDescription [CkJsonObject_stringOf $jResp "product.description"] set productContent [CkJsonObject_stringOf $jResp "product.content"] set productSetId [CkJsonObject_IntOf $jResp "product.set.id"] set productSetCreatedAt [CkJsonObject_stringOf $jResp "product.set.createdAt"] set productSetUpdatedAt [CkJsonObject_stringOf $jResp "product.set.updatedAt"] set productSetName [CkJsonObject_stringOf $jResp "product.set.name"] set productBrandResourceId [CkJsonObject_IntOf $jResp "product.brand.resource.id"] set productBrandResourceUrl [CkJsonObject_stringOf $jResp "product.brand.resource.url"] set productBrandResourceLink [CkJsonObject_stringOf $jResp "product.brand.resource.link"] set productCategoriesResourceId [CkJsonObject_BoolOf $jResp "product.categories.resource.id"] set productCategoriesResourceUrl [CkJsonObject_stringOf $jResp "product.categories.resource.url"] set productCategoriesResourceLink [CkJsonObject_stringOf $jResp "product.categories.resource.link"] set productDeliverydateResourceId [CkJsonObject_IntOf $jResp "product.deliverydate.resource.id"] set productDeliverydateResourceUrl [CkJsonObject_stringOf $jResp "product.deliverydate.resource.url"] set productDeliverydateResourceLink [CkJsonObject_stringOf $jResp "product.deliverydate.resource.link"] set productImageCreatedAt [CkJsonObject_stringOf $jResp "product.image.createdAt"] set productImageUpdatedAt [CkJsonObject_stringOf $jResp "product.image.updatedAt"] set productImageExtension [CkJsonObject_stringOf $jResp "product.image.extension"] set productImageSize [CkJsonObject_IntOf $jResp "product.image.size"] set productImageTitle [CkJsonObject_stringOf $jResp "product.image.title"] set productImageThumb [CkJsonObject_stringOf $jResp "product.image.thumb"] set productImageSrc [CkJsonObject_stringOf $jResp "product.image.src"] set productImagesResourceId [CkJsonObject_BoolOf $jResp "product.images.resource.id"] set productImagesResourceUrl [CkJsonObject_stringOf $jResp "product.images.resource.url"] set productImagesResourceLink [CkJsonObject_stringOf $jResp "product.images.resource.link"] set productRelationsResourceId [CkJsonObject_BoolOf $jResp "product.relations.resource.id"] set productRelationsResourceUrl [CkJsonObject_stringOf $jResp "product.relations.resource.url"] set productRelationsResourceLink [CkJsonObject_stringOf $jResp "product.relations.resource.link"] set productMetafieldsResourceId [CkJsonObject_BoolOf $jResp "product.metafields.resource.id"] set productMetafieldsResourceUrl [CkJsonObject_stringOf $jResp "product.metafields.resource.url"] set productMetafieldsResourceLink [CkJsonObject_stringOf $jResp "product.metafields.resource.link"] set productReviewsResourceId [CkJsonObject_BoolOf $jResp "product.reviews.resource.id"] set productReviewsResourceUrl [CkJsonObject_stringOf $jResp "product.reviews.resource.url"] set productReviewsResourceLink [CkJsonObject_stringOf $jResp "product.reviews.resource.link"] set productType [CkJsonObject_BoolOf $jResp "product.type"] set productAttributesResourceId [CkJsonObject_BoolOf $jResp "product.attributes.resource.id"] set productAttributesResourceUrl [CkJsonObject_stringOf $jResp "product.attributes.resource.url"] set productAttributesResourceLink [CkJsonObject_stringOf $jResp "product.attributes.resource.link"] set productSupplierResourceId [CkJsonObject_IntOf $jResp "product.supplier.resource.id"] set productSupplierResourceUrl [CkJsonObject_stringOf $jResp "product.supplier.resource.url"] set productSupplierResourceLink [CkJsonObject_stringOf $jResp "product.supplier.resource.link"] set productTagsResourceId [CkJsonObject_BoolOf $jResp "product.tags.resource.id"] set productTagsResourceUrl [CkJsonObject_stringOf $jResp "product.tags.resource.url"] set productTagsResourceLink [CkJsonObject_stringOf $jResp "product.tags.resource.link"] set productVariantsResourceId [CkJsonObject_BoolOf $jResp "product.variants.resource.id"] set productVariantsResourceUrl [CkJsonObject_stringOf $jResp "product.variants.resource.url"] set productVariantsResourceLink [CkJsonObject_stringOf $jResp "product.variants.resource.link"] set productMovementsResourceId [CkJsonObject_BoolOf $jResp "product.movements.resource.id"] set productMovementsResourceUrl [CkJsonObject_stringOf $jResp "product.movements.resource.url"] set productMovementsResourceLink [CkJsonObject_stringOf $jResp "product.movements.resource.link"] set i 0 set count_i [CkJsonObject_SizeOfArray $jResp "product.set.options"] while {$i < $count_i} { CkJsonObject_put_I $jResp $i set id [CkJsonObject_IntOf $jResp "product.set.options[i].id"] set sortOrder [CkJsonObject_IntOf $jResp "product.set.options[i].sortOrder"] set name [CkJsonObject_stringOf $jResp "product.set.options[i].name"] set j 0 set count_j [CkJsonObject_SizeOfArray $jResp "product.set.options[i].values"] while {$j < $count_j} { CkJsonObject_put_J $jResp $j set id [CkJsonObject_IntOf $jResp "product.set.options[i].values[j].id"] set sortOrder [CkJsonObject_IntOf $jResp "product.set.options[i].values[j].sortOrder"] set name [CkJsonObject_stringOf $jResp "product.set.options[i].values[j].name"] set j [expr $j + 1] } set i [expr $i + 1] } delete_CkHttp $http delete_CkStringBuilder $sbResponseBody delete_CkJsonObject $jResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.