PHP code example of google / cloud-private-catalog
1. Go to this page and download the library: Download google/cloud-private-catalog library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
google / cloud-private-catalog example snippets
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\PrivateCatalog\V1beta1\Client\PrivateCatalogClient;
use Google\Cloud\PrivateCatalog\V1beta1\Product;
use Google\Cloud\PrivateCatalog\V1beta1\SearchProductsRequest;
// Create a client.
$privateCatalogClient = new PrivateCatalogClient();
// Prepare the request message.
$request = (new SearchProductsRequest())
->setResource($resource);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $privateCatalogClient->searchProducts($request);
/** @var Product $element */
foreach ($response as $element) {
printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}