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
(PowerBuilder) Shopify Get all products, showing only some attributesGet all products, showing only some attributes
integer li_rc oleobject loo_Rest integer li_Success oleobject loo_SbJson oleobject loo_Json integer i integer li_Count_i integer li_Id string ls_Title integer j integer li_Count_j integer li_Product_id integer li_Position string ls_Created_at string ls_Updated_at integer li_Width integer li_Height string ls_Src integer k integer li_Count_k integer li_IntVal loo_Rest = create oleobject // Use "Chilkat_9_5_0.Rest" for versions of Chilkat < 10.0.0 li_rc = loo_Rest.ConnectToNewObject("Chilkat.Rest") if li_rc < 0 then destroy loo_Rest MessageBox("Error","Connecting to COM object failed") return end if loo_Rest.SetAuthBasic("SHOPIFY_PRIVATE_API_KEY","SHOPIFY_PRIVATE_API_KEY") li_Success = loo_Rest.Connect("chilkat.myshopify.com",443,1,1) if li_Success <> 1 then Write-Debug loo_Rest.LastErrorText destroy loo_Rest return end if loo_SbJson = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbJson.ConnectToNewObject("Chilkat.StringBuilder") li_Success = loo_Rest.FullRequestNoBodySb("GET","/admin/products.json?fields=id,images,title",loo_SbJson) if li_Success <> 1 then Write-Debug loo_Rest.LastErrorText destroy loo_Rest destroy loo_SbJson return end if if loo_Rest.ResponseStatusCode <> 200 then Write-Debug "Received error response code: " + string(loo_Rest.ResponseStatusCode) Write-Debug "Response body:" Write-Debug loo_SbJson.GetAsString() destroy loo_Rest destroy loo_SbJson 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_Json.LoadSb(loo_SbJson) // The following code parses the JSON response. // A sample JSON response is shown below the sample code. i = 0 li_Count_i = loo_Json.SizeOfArray("products") do while i < li_Count_i loo_Json.I = i li_Id = loo_Json.IntOf("products[i].id") ls_Title = loo_Json.StringOf("products[i].title") j = 0 li_Count_j = loo_Json.SizeOfArray("products[i].images") do while j < li_Count_j loo_Json.J = j li_Id = loo_Json.IntOf("products[i].images[j].id") li_Product_id = loo_Json.IntOf("products[i].images[j].product_id") li_Position = loo_Json.IntOf("products[i].images[j].position") ls_Created_at = loo_Json.StringOf("products[i].images[j].created_at") ls_Updated_at = loo_Json.StringOf("products[i].images[j].updated_at") li_Width = loo_Json.IntOf("products[i].images[j].width") li_Height = loo_Json.IntOf("products[i].images[j].height") ls_Src = loo_Json.StringOf("products[i].images[j].src") k = 0 li_Count_k = loo_Json.SizeOfArray("products[i].images[j].variant_ids") do while k < li_Count_k loo_Json.K = k li_IntVal = loo_Json.IntOf("products[i].images[j].variant_ids[k]") k = k + 1 loop j = j + 1 loop i = i + 1 loop // A sample JSON response body that is parsed by the above code: // { // "products": [ // { // "id": 632910392, // "title": "IPod Nano - 8GB", // "images": [ // { // "id": 850703190, // "product_id": 632910392, // "position": 1, // "created_at": "2017-09-22T14:08:02-04:00", // "updated_at": "2017-09-22T14:08:02-04:00", // "width": 123, // "height": 456, // "src": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/products\/ipod-nano.png?v=1506103682", // "variant_ids": [ // ] // }, // { // "id": 562641783, // "product_id": 632910392, // "position": 2, // "created_at": "2017-09-22T14:08:02-04:00", // "updated_at": "2017-09-22T14:08:02-04:00", // "width": 123, // "height": 456, // "src": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/products\/ipod-nano-2.png?v=1506103682", // "variant_ids": [ // 808950810 // ] // } // ] // }, // { // "id": 921728736, // "title": "IPod Touch 8GB", // "images": [ // ] // } // ] // } Write-Debug "Example Completed." destroy loo_Rest destroy loo_SbJson destroy loo_Json |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.