PHP code example of google / shopping-merchant-reports
1. Go to this page and download the library: Download google/shopping-merchant-reports 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 / shopping-merchant-reports example snippets
Google\ApiCore\ApiException;
Google\ApiCore\PagedListResponse;
Google\Shopping\Merchant\Reports\V1beta\Client\ReportServiceClient;
Google\Shopping\Merchant\Reports\V1beta\ReportRow;
Google\Shopping\Merchant\Reports\V1beta\SearchRequest;
// Create a client.
$reportServiceClient = new ReportServiceClient();
// Prepare the request message.
$request = (new SearchRequest())
->setParent($parent)
->setQuery($query);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $reportServiceClient->search($request);
/** @var ReportRow $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());
}