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
(VB.NET) 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
' This example assumes the Chilkat API to have been previously unlocked. ' See Global Unlock Sample for sample code. Dim http As New Chilkat.Http Dim success As Boolean ' 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 http.Login = "API_KEY" http.Password = "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/ Dim sbResponseBody As New Chilkat.StringBuilder success = http.QuickGetSb("https://api.webshopapp.com/en/products.json",sbResponseBody) If (success = False) Then Debug.WriteLine(http.LastErrorText) Exit Sub End If Dim jResp As New Chilkat.JsonObject jResp.LoadSb(sbResponseBody) jResp.EmitCompact = False Debug.WriteLine("Response Body:") Debug.WriteLine(jResp.Emit()) Dim respStatusCode As Integer = http.LastStatus Debug.WriteLine("Response Status Code = " & respStatusCode) If (respStatusCode >= 400) Then Debug.WriteLine("Response Header:") Debug.WriteLine(http.LastHeader) Debug.WriteLine("Failed.") Exit Sub End If ' 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 Dim id As Integer Dim sortOrder As Integer Dim name As String Dim j As Integer Dim count_j As Integer Dim productId As Integer = jResp.IntOf("product.id") Dim productCreatedAt As String = jResp.StringOf("product.createdAt") Dim productUpdatedAt As String = jResp.StringOf("product.updatedAt") Dim productIsVisible As Boolean = jResp.BoolOf("product.isVisible") Dim productVisibility As String = jResp.StringOf("product.visibility") Dim productHasMatrix As Boolean = jResp.BoolOf("product.hasMatrix") Dim productData01 As String = jResp.StringOf("product.data01") Dim productData02 As String = jResp.StringOf("product.data02") Dim productData03 As String = jResp.StringOf("product.data03") Dim productUrl As String = jResp.StringOf("product.url") Dim productTitle As String = jResp.StringOf("product.title") Dim productFulltitle As String = jResp.StringOf("product.fulltitle") Dim productDescription As String = jResp.StringOf("product.description") Dim productContent As String = jResp.StringOf("product.content") Dim productSetId As Integer = jResp.IntOf("product.set.id") Dim productSetCreatedAt As String = jResp.StringOf("product.set.createdAt") Dim productSetUpdatedAt As String = jResp.StringOf("product.set.updatedAt") Dim productSetName As String = jResp.StringOf("product.set.name") Dim productBrandResourceId As Integer = jResp.IntOf("product.brand.resource.id") Dim productBrandResourceUrl As String = jResp.StringOf("product.brand.resource.url") Dim productBrandResourceLink As String = jResp.StringOf("product.brand.resource.link") Dim productCategoriesResourceId As Boolean = jResp.BoolOf("product.categories.resource.id") Dim productCategoriesResourceUrl As String = jResp.StringOf("product.categories.resource.url") Dim productCategoriesResourceLink As String = jResp.StringOf("product.categories.resource.link") Dim productDeliverydateResourceId As Integer = jResp.IntOf("product.deliverydate.resource.id") Dim productDeliverydateResourceUrl As String = jResp.StringOf("product.deliverydate.resource.url") Dim productDeliverydateResourceLink As String = jResp.StringOf("product.deliverydate.resource.link") Dim productImageCreatedAt As String = jResp.StringOf("product.image.createdAt") Dim productImageUpdatedAt As String = jResp.StringOf("product.image.updatedAt") Dim productImageExtension As String = jResp.StringOf("product.image.extension") Dim productImageSize As Integer = jResp.IntOf("product.image.size") Dim productImageTitle As String = jResp.StringOf("product.image.title") Dim productImageThumb As String = jResp.StringOf("product.image.thumb") Dim productImageSrc As String = jResp.StringOf("product.image.src") Dim productImagesResourceId As Boolean = jResp.BoolOf("product.images.resource.id") Dim productImagesResourceUrl As String = jResp.StringOf("product.images.resource.url") Dim productImagesResourceLink As String = jResp.StringOf("product.images.resource.link") Dim productRelationsResourceId As Boolean = jResp.BoolOf("product.relations.resource.id") Dim productRelationsResourceUrl As String = jResp.StringOf("product.relations.resource.url") Dim productRelationsResourceLink As String = jResp.StringOf("product.relations.resource.link") Dim productMetafieldsResourceId As Boolean = jResp.BoolOf("product.metafields.resource.id") Dim productMetafieldsResourceUrl As String = jResp.StringOf("product.metafields.resource.url") Dim productMetafieldsResourceLink As String = jResp.StringOf("product.metafields.resource.link") Dim productReviewsResourceId As Boolean = jResp.BoolOf("product.reviews.resource.id") Dim productReviewsResourceUrl As String = jResp.StringOf("product.reviews.resource.url") Dim productReviewsResourceLink As String = jResp.StringOf("product.reviews.resource.link") Dim productType As Boolean = jResp.BoolOf("product.type") Dim productAttributesResourceId As Boolean = jResp.BoolOf("product.attributes.resource.id") Dim productAttributesResourceUrl As String = jResp.StringOf("product.attributes.resource.url") Dim productAttributesResourceLink As String = jResp.StringOf("product.attributes.resource.link") Dim productSupplierResourceId As Integer = jResp.IntOf("product.supplier.resource.id") Dim productSupplierResourceUrl As String = jResp.StringOf("product.supplier.resource.url") Dim productSupplierResourceLink As String = jResp.StringOf("product.supplier.resource.link") Dim productTagsResourceId As Boolean = jResp.BoolOf("product.tags.resource.id") Dim productTagsResourceUrl As String = jResp.StringOf("product.tags.resource.url") Dim productTagsResourceLink As String = jResp.StringOf("product.tags.resource.link") Dim productVariantsResourceId As Boolean = jResp.BoolOf("product.variants.resource.id") Dim productVariantsResourceUrl As String = jResp.StringOf("product.variants.resource.url") Dim productVariantsResourceLink As String = jResp.StringOf("product.variants.resource.link") Dim productMovementsResourceId As Boolean = jResp.BoolOf("product.movements.resource.id") Dim productMovementsResourceUrl As String = jResp.StringOf("product.movements.resource.url") Dim productMovementsResourceLink As String = jResp.StringOf("product.movements.resource.link") Dim i As Integer = 0 Dim count_i As Integer = jResp.SizeOfArray("product.set.options") While i < count_i jResp.I = i id = jResp.IntOf("product.set.options[i].id") sortOrder = jResp.IntOf("product.set.options[i].sortOrder") name = jResp.StringOf("product.set.options[i].name") j = 0 count_j = jResp.SizeOfArray("product.set.options[i].values") While j < count_j jResp.J = j id = jResp.IntOf("product.set.options[i].values[j].id") sortOrder = jResp.IntOf("product.set.options[i].values[j].sortOrder") name = jResp.StringOf("product.set.options[i].values[j].name") j = j + 1 End While i = i + 1 End While |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.