Perl
Perl
Shopify Receive Count of All Products in a Collection
See more Shopify Examples
Get a count of all products of a given collectionChilkat Perl Downloads
use strict;
use warnings;
use Chilkat2;
my $rest = Chilkat2::Rest->new;
$rest->SetAuthBasic('SHOPIFY_PRIVATE_API_KEY', 'SHOPIFY_PRIVATE_API_KEY');
my $success = $rest->Connect('chilkat.myshopify.com', 443, 1, 1);
if (!$success) {
print $rest->LastErrorText, "\n";
exit;
}
my $sbJson = Chilkat2::StringBuilder->new;
$success = $rest->FullRequestNoBodySb('GET', '/admin/products/count.json?collection_id=841564295 ', $sbJson);
if (!$success) {
print $rest->LastErrorText, "\n";
exit;
}
if ($rest->ResponseStatusCode != 200) {
print 'Received error response code: ', $rest->ResponseStatusCode, "\n";
print "Response body:\n";
print $sbJson->GetAsString(), "\n";
exit;
}
my $json = Chilkat2::JsonObject->new;
$json->LoadSb($sbJson);
# The following code parses the JSON response.
# A sample JSON response is shown below the sample code.
my $count = $json->IntOf('count');
# A sample JSON response body that is parsed by the above code:
# {
# "count": 1
# }
print "Example Completed.\n";