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
(AutoIt) 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. $oHttp = ObjCreate("Chilkat.Http") Local $bSuccess ; 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 $oHttp.Login = "API_KEY" $oHttp.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/ $oSbResponseBody = ObjCreate("Chilkat.StringBuilder") $bSuccess = $oHttp.QuickGetSb("https://api.webshopapp.com/en/products.json",$oSbResponseBody) If ($bSuccess = False) Then ConsoleWrite($oHttp.LastErrorText & @CRLF) Exit EndIf $oJResp = ObjCreate("Chilkat.JsonObject") $oJResp.LoadSb($oSbResponseBody) $oJResp.EmitCompact = False ConsoleWrite("Response Body:" & @CRLF) ConsoleWrite($oJResp.Emit() & @CRLF) Local $iRespStatusCode = $oHttp.LastStatus ConsoleWrite("Response Status Code = " & $iRespStatusCode & @CRLF) If ($iRespStatusCode >= 400) Then ConsoleWrite("Response Header:" & @CRLF) ConsoleWrite($oHttp.LastHeader & @CRLF) ConsoleWrite("Failed." & @CRLF) Exit EndIf ; 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 Local $id Local $iSortOrder Local $sName Local $iJ Local $iCount_j Local $iProductId = $oJResp.IntOf("product.id") Local $sProductCreatedAt = $oJResp.StringOf("product.createdAt") Local $sProductUpdatedAt = $oJResp.StringOf("product.updatedAt") Local $bProductIsVisible = $oJResp.BoolOf("product.isVisible") Local $sProductVisibility = $oJResp.StringOf("product.visibility") Local $bProductHasMatrix = $oJResp.BoolOf("product.hasMatrix") Local $sProductData01 = $oJResp.StringOf("product.data01") Local $sProductData02 = $oJResp.StringOf("product.data02") Local $sProductData03 = $oJResp.StringOf("product.data03") Local $sProductUrl = $oJResp.StringOf("product.url") Local $sProductTitle = $oJResp.StringOf("product.title") Local $sProductFulltitle = $oJResp.StringOf("product.fulltitle") Local $sProductDescription = $oJResp.StringOf("product.description") Local $sProductContent = $oJResp.StringOf("product.content") Local $iProductSetId = $oJResp.IntOf("product.set.id") Local $sProductSetCreatedAt = $oJResp.StringOf("product.set.createdAt") Local $sProductSetUpdatedAt = $oJResp.StringOf("product.set.updatedAt") Local $sProductSetName = $oJResp.StringOf("product.set.name") Local $iProductBrandResourceId = $oJResp.IntOf("product.brand.resource.id") Local $sProductBrandResourceUrl = $oJResp.StringOf("product.brand.resource.url") Local $sProductBrandResourceLink = $oJResp.StringOf("product.brand.resource.link") Local $bProductCategoriesResourceId = $oJResp.BoolOf("product.categories.resource.id") Local $sProductCategoriesResourceUrl = $oJResp.StringOf("product.categories.resource.url") Local $sProductCategoriesResourceLink = $oJResp.StringOf("product.categories.resource.link") Local $iProductDeliverydateResourceId = $oJResp.IntOf("product.deliverydate.resource.id") Local $sProductDeliverydateResourceUrl = $oJResp.StringOf("product.deliverydate.resource.url") Local $sProductDeliverydateResourceLink = $oJResp.StringOf("product.deliverydate.resource.link") Local $sProductImageCreatedAt = $oJResp.StringOf("product.image.createdAt") Local $sProductImageUpdatedAt = $oJResp.StringOf("product.image.updatedAt") Local $sProductImageExtension = $oJResp.StringOf("product.image.extension") Local $iProductImageSize = $oJResp.IntOf("product.image.size") Local $sProductImageTitle = $oJResp.StringOf("product.image.title") Local $sProductImageThumb = $oJResp.StringOf("product.image.thumb") Local $sProductImageSrc = $oJResp.StringOf("product.image.src") Local $bProductImagesResourceId = $oJResp.BoolOf("product.images.resource.id") Local $sProductImagesResourceUrl = $oJResp.StringOf("product.images.resource.url") Local $sProductImagesResourceLink = $oJResp.StringOf("product.images.resource.link") Local $bProductRelationsResourceId = $oJResp.BoolOf("product.relations.resource.id") Local $sProductRelationsResourceUrl = $oJResp.StringOf("product.relations.resource.url") Local $sProductRelationsResourceLink = $oJResp.StringOf("product.relations.resource.link") Local $bProductMetafieldsResourceId = $oJResp.BoolOf("product.metafields.resource.id") Local $sProductMetafieldsResourceUrl = $oJResp.StringOf("product.metafields.resource.url") Local $sProductMetafieldsResourceLink = $oJResp.StringOf("product.metafields.resource.link") Local $bProductReviewsResourceId = $oJResp.BoolOf("product.reviews.resource.id") Local $sProductReviewsResourceUrl = $oJResp.StringOf("product.reviews.resource.url") Local $sProductReviewsResourceLink = $oJResp.StringOf("product.reviews.resource.link") Local $bProductType = $oJResp.BoolOf("product.type") Local $bProductAttributesResourceId = $oJResp.BoolOf("product.attributes.resource.id") Local $sProductAttributesResourceUrl = $oJResp.StringOf("product.attributes.resource.url") Local $sProductAttributesResourceLink = $oJResp.StringOf("product.attributes.resource.link") Local $iProductSupplierResourceId = $oJResp.IntOf("product.supplier.resource.id") Local $sProductSupplierResourceUrl = $oJResp.StringOf("product.supplier.resource.url") Local $sProductSupplierResourceLink = $oJResp.StringOf("product.supplier.resource.link") Local $bProductTagsResourceId = $oJResp.BoolOf("product.tags.resource.id") Local $sProductTagsResourceUrl = $oJResp.StringOf("product.tags.resource.url") Local $sProductTagsResourceLink = $oJResp.StringOf("product.tags.resource.link") Local $bProductVariantsResourceId = $oJResp.BoolOf("product.variants.resource.id") Local $sProductVariantsResourceUrl = $oJResp.StringOf("product.variants.resource.url") Local $sProductVariantsResourceLink = $oJResp.StringOf("product.variants.resource.link") Local $bProductMovementsResourceId = $oJResp.BoolOf("product.movements.resource.id") Local $sProductMovementsResourceUrl = $oJResp.StringOf("product.movements.resource.url") Local $sProductMovementsResourceLink = $oJResp.StringOf("product.movements.resource.link") Local $i = 0 Local $iCount_i = $oJResp.SizeOfArray("product.set.options") While $i < $iCount_i $oJResp.I = $i $id = $oJResp.IntOf("product.set.options[i].id") $iSortOrder = $oJResp.IntOf("product.set.options[i].sortOrder") $sName = $oJResp.StringOf("product.set.options[i].name") $iJ = 0 $iCount_j = $oJResp.SizeOfArray("product.set.options[i].values") While $iJ < $iCount_j $oJResp.J = $iJ $id = $oJResp.IntOf("product.set.options[i].values[j].id") $iSortOrder = $oJResp.IntOf("product.set.options[i].values[j].sortOrder") $sName = $oJResp.StringOf("product.set.options[i].values[j].name") $iJ = $iJ + 1 Wend $i = $i + 1 Wend |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.