بررسی محصول بخش مهمی از تجربه خرید برای مشتریان است. این رتبهبندیها و بررسیها به مشتریان در تحقیقات محصول و تصمیمگیری برای خرید کمک میکند. بررسی های مثبت محصول می تواند مشتریان واجد شرایط بیشتری را به صفحات محصول فروشنده سوق دهد. منابع عبارتند از فروشندگان، جمعآوریکنندگان نقد، سایتهای بررسی و کاربران گوگل.
این صفحه توضیح می دهد که چگونه می توانید نظرات محصول را با استفاده از Merchant API مدیریت کنید.
پیش نیازها
گوگل به شما نیاز دارد که اطلاعات خاصی را ارائه دهید. شما باید موارد زیر را داشته باشید:
- یک فید بررسی محصول فعال در Google Merchant Center.
- حساب شما باید در برنامه رتبه بندی محصولات ثبت نام شود. اگر مطمئن نیستید که قبلا ثبت نام کرده اید، مرکز تجاری را بررسی کنید. اگر ثبت نام نکرده اید، درباره ثبت نام در برنامه رتبه بندی محصول بیشتر بیاموزید.
- برای بررسی محصولات با استفاده از Merchant API، با استفاده از این فرم درخواست ارسال کنید.
یک منبع داده ایجاد کنید
از datasource.create
API برای ایجاد فید بررسی محصول استفاده کنید. اگر فید بررسی محصول موجود در دسترس است، از accounts.dataSources.get
برای واکشی accounts.dataSources.name
استفاده کنید. فرم درخواست به شرح زیر است:
POST https://merchantapi.googleapis.com/datasources/v1beta/accounts/{account}/dataSources/{datasource}
مثال
مثال یک درخواست و پاسخ معمولی را نشان می دهد.
درخواست کنید
POST https://merchantapi.googleapis.com/datasources/v1beta/accounts/123/dataSources {"displayName": "test api feed", "productReviewDataSource":{} }
پاسخ
{
"name": "accounts/123/dataSources/1000000573361824",
"dataSourceId": "1000000573361824",
"displayName": "test api feed",
"productReviewDataSource": {},
"input": "API"
}
برای اطلاعات بیشتر، مروری بر API منابع داده تجاری را ببینید.
ایجاد بررسی محصول
میتوانید از روش accounts.productreviews.insert
برای ایجاد یا بهروزرسانی بررسی محصول استفاده کنید. روش accounts.productreviews.insert
یک منبع productreview
و نام منبع داده را به عنوان ورودی می گیرد. در صورت موفقیت، productreview
جدید یا به روز شده را برمی گرداند. برای ایجاد بررسی محصول، باید datasource.name
داشته باشید.
فرم درخواست:
POST https://merchantapi.googleapis.com/reviews/v1beta/{parent=accounts/{ACCOUNT_ID} /}productReviews:insert
نمونه درخواست زیر نشان می دهد که چگونه می توانید یک بررسی محصول ایجاد کنید.
POST https://merchantapi.googleapis.com/reviews/v1beta/accounts/{ACCOUNT_ID} /productReviews:insert?dataSource=accounts/{ACCOUNT_ID} /dataSources/{DATASOURCE_ID}
productReviewId = 'my_product_review'
attributes {
aggregatorName = 'aggregator_name'
subclientName = 'subclient_name'
publisherName = 'publisher_name'
publisherFavicon = 'https://www.google.com/favicon.ico'
reviewerId = 'reviewer_id'
reviewerIsAnonymous = false
reviewerUsername = 'reviewer_username'
reviewLanguage = 'en'
reviewCountry = 'US'
reviewTime = '2024-04-01T00:00:00Z'
title = 'Incredible product'
content = 'This is an incredible product.'
pros = ['pro1', 'pro2']
cons = ['con1', 'con2']
reviewLink = {
type = 'SINGLETON'
link = 'https://www.google.com'
}
reviewerImageLink = 'https://www.google.com/reviewer.png'
minRating = 1
maxRating = 10
rating = 8.5
productName = 'product_name'
productLink = 'https://www.google.com/product'
asins = ['asin1', 'asin2']
gtins = ['gtin1', 'gtin2']
mpns = ['mpn1', 'mpn2']
skus = ['sku1', 'sku2']
brands = ['brand1', 'brand2']
isSpam = false
collectionMethod = 'POST_FULFILLMENT'
transactionId = 'transaction_id'
}
پس از ایجاد بررسی محصول، ممکن است چند دقیقه طول بکشد تا بررسی منتشر شود.
در اینجا نمونه ای وجود دارد که می توانید از آن برای درج چندین بررسی محصول به صورت ناهمزمان استفاده کنید:
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.reviews.v1beta.ListProductReviewsRequest;
import com.google.shopping.merchant.reviews.v1beta.ProductReview;
import com.google.shopping.merchant.reviews.v1beta.ProductReviewsServiceClient;
import com.google.shopping.merchant.reviews.v1beta.ProductReviewsServiceClient.ListProductReviewsPagedResponse;
import com.google.shopping.merchant.reviews.v1beta.ProductReviewsServiceSettings;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/** This class demonstrates how to list all the product reviews in a given account. */
public class ListProductReviewsSample {
public static void listProductReviews(String accountId) throws Exception {
GoogleCredentials credential = new Authenticator().authenticate();
ProductReviewsServiceSettings productReviewsServiceSettings =
ProductReviewsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
try (ProductReviewsServiceClient productReviewsServiceClient =
ProductReviewsServiceClient.create(productReviewsServiceSettings)) {
ListProductReviewsRequest request =
ListProductReviewsRequest.newBuilder()
.setParent(String.format("accounts/%s", accountId))
.build();
System.out.println("Sending list product reviews request:");
ListProductReviewsPagedResponse response =
productReviewsServiceClient.listProductReviews(request);
int count = 0;
// Iterates over all rows in all pages and prints all product reviews.
for (ProductReview element : response.iterateAll()) {
System.out.println(element);
count++;
}
System.out.print("The following count of elements were returned: ");
System.out.println(count);
} catch (Exception e) {
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
listProductReviews(config.getAccountId().toString());
}
}
بازیابی بررسی محصول
برای مشاهده بررسی محصول، از accounts.productreviews.get
استفاده کنید. این فقط خواندنی است. accountId
شما و شناسه بررسی محصول به عنوان بخشی از قسمت نام نیاز دارد. روش GET
منبع بررسی محصول مربوطه را برمی گرداند.
GET https://merchantapi.googleapis.com/reviews/v1beta/{name=accounts/{ACCOUNT_ID} /productReviews/*}
در اینجا نمونه ای وجود دارد که می توانید از آن برای بازیابی بررسی محصول استفاده کنید:
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.reviews.v1beta.GetProductReviewRequest;
import com.google.shopping.merchant.reviews.v1beta.ProductReview;
import com.google.shopping.merchant.reviews.v1beta.ProductReviewsServiceClient;
import com.google.shopping.merchant.reviews.v1beta.ProductReviewsServiceSettings;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/** This class demonstrates how to get a product review. */
public class GetProductReviewSample {
public static void getProductReview(String accountId, String productReviewId) throws Exception {
GoogleCredentials credential = new Authenticator().authenticate();
ProductReviewsServiceSettings productReviewsServiceSettings =
ProductReviewsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
try (ProductReviewsServiceClient productReviewsServiceClient =
ProductReviewsServiceClient.create(productReviewsServiceSettings)) {
GetProductReviewRequest request =
GetProductReviewRequest.newBuilder()
.setName(String.format("accounts/%s/productReviews/%s", accountId, productReviewId))
.build();
System.out.println("Sending get product review request:");
ProductReview response = productReviewsServiceClient.getProductReview(request);
System.out.println("Product review retrieved successfully:");
System.out.println(response.getName());
} catch (Exception e) {
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
String productReviewId = "YOUR_PRODUCT_REVIEW_ID";
getProductReview(config.getAccountId().toString(), productReviewId);
}
}
بررسی های محصول را لیست کنید
شما می توانید از روش productreviews.list
برای مشاهده تمام بررسی های محصول ایجاد شده استفاده کنید.
GET https://merchantapi.googleapis.com/reviews/v1beta/{parent=accounts/{ACCOUNT_ID} }/productReviews
در اینجا نمونهای وجود دارد که میتوانید از آن برای فهرست کردن تمام نظرات یک محصول استفاده کنید:
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.reviews.v1beta.ListProductReviewsRequest;
import com.google.shopping.merchant.reviews.v1beta.ProductReview;
import com.google.shopping.merchant.reviews.v1beta.ProductReviewsServiceClient;
import com.google.shopping.merchant.reviews.v1beta.ProductReviewsServiceClient.ListProductReviewsPagedResponse;
import com.google.shopping.merchant.reviews.v1beta.ProductReviewsServiceSettings;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/** This class demonstrates how to list all the product reviews in a given account. */
public class ListProductReviewsSample {
public static void listProductReviews(String accountId) throws Exception {
GoogleCredentials credential = new Authenticator().authenticate();
ProductReviewsServiceSettings productReviewsServiceSettings =
ProductReviewsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
try (ProductReviewsServiceClient productReviewsServiceClient =
ProductReviewsServiceClient.create(productReviewsServiceSettings)) {
ListProductReviewsRequest request =
ListProductReviewsRequest.newBuilder()
.setParent(String.format("accounts/%s", accountId))
.build();
System.out.println("Sending list product reviews request:");
ListProductReviewsPagedResponse response =
productReviewsServiceClient.listProductReviews(request);
int count = 0;
// Iterates over all rows in all pages and prints all product reviews.
for (ProductReview element : response.iterateAll()) {
System.out.println(element);
count++;
}
System.out.print("The following count of elements were returned: ");
System.out.println(count);
} catch (Exception e) {
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
listProductReviews(config.getAccountId().toString());
}
}
نظرات محصول را حذف کنید
برای حذف بررسی محصول، از accounts.productreviews.delete
استفاده کنید. مشابه روش GET
، این روش نیازمند فیلد نام بررسی محصول است که در حین ایجاد بازگردانده شده است.
DELETE https://merchantapi.googleapis.com/reviews/v1beta/{name=accounts/{ACCOUNT_ID} /productReviews/*}
در اینجا نمونه ای وجود دارد که می توانید از آن برای حذف بررسی محصول استفاده کنید:
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.reviews.v1beta.DeleteProductReviewRequest;
import com.google.shopping.merchant.reviews.v1beta.ProductReviewsServiceClient;
import com.google.shopping.merchant.reviews.v1beta.ProductReviewsServiceSettings;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/** This class demonstrates how to delete a product review. */
public class DeleteProductReviewSample {
public static void deleteProductReview(String accountId, String productReviewId)
throws Exception {
GoogleCredentials credential = new Authenticator().authenticate();
ProductReviewsServiceSettings productReviewsServiceSettings =
ProductReviewsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
try (ProductReviewsServiceClient productReviewsServiceClient =
ProductReviewsServiceClient.create(productReviewsServiceSettings)) {
DeleteProductReviewRequest request =
DeleteProductReviewRequest.newBuilder()
.setName(String.format("accounts/%s/productReviews/%s", accountId, productReviewId))
.build();
System.out.println("Sending delete product review request:");
productReviewsServiceClient.deleteProductReview(request);
System.out.println("Product review deleted successfully");
} catch (Exception e) {
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
String productReviewId = "YOUR_PRODUCT_REVIEW_ID";
deleteProductReview(config.getAccountId().toString(), productReviewId);
}
}
وضعیت بررسی محصول
منبع بررسی محصول دارای وضعیتی مشابه سایر APIها است که بخشی جدایی ناپذیر از منبع است و از ساختار موضوع و مقصد مشابهی پیروی می کند.
،بررسی محصول بخش مهمی از تجربه خرید برای مشتریان است. این رتبهبندیها و بررسیها به مشتریان در تحقیقات محصول و تصمیمگیری برای خرید کمک میکند. بررسی های مثبت محصول می تواند مشتریان واجد شرایط بیشتری را به صفحات محصول فروشنده سوق دهد. منابع عبارتند از فروشندگان، جمعآوریکنندگان نقد، سایتهای بررسی و کاربران گوگل.
این صفحه توضیح می دهد که چگونه می توانید نظرات محصول را با استفاده از Merchant API مدیریت کنید.
پیش نیازها
گوگل به شما نیاز دارد که اطلاعات خاصی را ارائه دهید. شما باید موارد زیر را داشته باشید:
- یک فید بررسی محصول فعال در Google Merchant Center.
- حساب شما باید در برنامه رتبه بندی محصولات ثبت نام شود. اگر مطمئن نیستید که قبلا ثبت نام کرده اید، مرکز تجاری را بررسی کنید. اگر ثبت نام نکرده اید، درباره ثبت نام در برنامه رتبه بندی محصول بیشتر بیاموزید.
- برای بررسی محصولات با استفاده از Merchant API، با استفاده از این فرم درخواست ارسال کنید.
یک منبع داده ایجاد کنید
از datasource.create
API برای ایجاد فید بررسی محصول استفاده کنید. اگر فید بررسی محصول موجود در دسترس است، از accounts.dataSources.get
برای واکشی accounts.dataSources.name
استفاده کنید. فرم درخواست به شرح زیر است:
POST https://merchantapi.googleapis.com/datasources/v1beta/accounts/{account}/dataSources/{datasource}
مثال
مثال یک درخواست و پاسخ معمولی را نشان می دهد.
درخواست کنید
POST https://merchantapi.googleapis.com/datasources/v1beta/accounts/123/dataSources {"displayName": "test api feed", "productReviewDataSource":{} }
پاسخ
{
"name": "accounts/123/dataSources/1000000573361824",
"dataSourceId": "1000000573361824",
"displayName": "test api feed",
"productReviewDataSource": {},
"input": "API"
}
برای اطلاعات بیشتر، مروری بر API منابع داده تجاری را ببینید.
ایجاد بررسی محصول
میتوانید از روش accounts.productreviews.insert
برای ایجاد یا بهروزرسانی بررسی محصول استفاده کنید. روش accounts.productreviews.insert
یک منبع productreview
و نام منبع داده را به عنوان ورودی می گیرد. در صورت موفقیت، productreview
جدید یا به روز شده را برمی گرداند. برای ایجاد بررسی محصول، باید datasource.name
داشته باشید.
فرم درخواست:
POST https://merchantapi.googleapis.com/reviews/v1beta/{parent=accounts/{ACCOUNT_ID} /}productReviews:insert
نمونه درخواست زیر نشان می دهد که چگونه می توانید یک بررسی محصول ایجاد کنید.
POST https://merchantapi.googleapis.com/reviews/v1beta/accounts/{ACCOUNT_ID} /productReviews:insert?dataSource=accounts/{ACCOUNT_ID} /dataSources/{DATASOURCE_ID}
productReviewId = 'my_product_review'
attributes {
aggregatorName = 'aggregator_name'
subclientName = 'subclient_name'
publisherName = 'publisher_name'
publisherFavicon = 'https://www.google.com/favicon.ico'
reviewerId = 'reviewer_id'
reviewerIsAnonymous = false
reviewerUsername = 'reviewer_username'
reviewLanguage = 'en'
reviewCountry = 'US'
reviewTime = '2024-04-01T00:00:00Z'
title = 'Incredible product'
content = 'This is an incredible product.'
pros = ['pro1', 'pro2']
cons = ['con1', 'con2']
reviewLink = {
type = 'SINGLETON'
link = 'https://www.google.com'
}
reviewerImageLink = 'https://www.google.com/reviewer.png'
minRating = 1
maxRating = 10
rating = 8.5
productName = 'product_name'
productLink = 'https://www.google.com/product'
asins = ['asin1', 'asin2']
gtins = ['gtin1', 'gtin2']
mpns = ['mpn1', 'mpn2']
skus = ['sku1', 'sku2']
brands = ['brand1', 'brand2']
isSpam = false
collectionMethod = 'POST_FULFILLMENT'
transactionId = 'transaction_id'
}
پس از ایجاد بررسی محصول، ممکن است چند دقیقه طول بکشد تا بررسی منتشر شود.
در اینجا نمونه ای وجود دارد که می توانید از آن برای درج چندین بررسی محصول به صورت ناهمزمان استفاده کنید:
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.reviews.v1beta.ListProductReviewsRequest;
import com.google.shopping.merchant.reviews.v1beta.ProductReview;
import com.google.shopping.merchant.reviews.v1beta.ProductReviewsServiceClient;
import com.google.shopping.merchant.reviews.v1beta.ProductReviewsServiceClient.ListProductReviewsPagedResponse;
import com.google.shopping.merchant.reviews.v1beta.ProductReviewsServiceSettings;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/** This class demonstrates how to list all the product reviews in a given account. */
public class ListProductReviewsSample {
public static void listProductReviews(String accountId) throws Exception {
GoogleCredentials credential = new Authenticator().authenticate();
ProductReviewsServiceSettings productReviewsServiceSettings =
ProductReviewsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
try (ProductReviewsServiceClient productReviewsServiceClient =
ProductReviewsServiceClient.create(productReviewsServiceSettings)) {
ListProductReviewsRequest request =
ListProductReviewsRequest.newBuilder()
.setParent(String.format("accounts/%s", accountId))
.build();
System.out.println("Sending list product reviews request:");
ListProductReviewsPagedResponse response =
productReviewsServiceClient.listProductReviews(request);
int count = 0;
// Iterates over all rows in all pages and prints all product reviews.
for (ProductReview element : response.iterateAll()) {
System.out.println(element);
count++;
}
System.out.print("The following count of elements were returned: ");
System.out.println(count);
} catch (Exception e) {
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
listProductReviews(config.getAccountId().toString());
}
}
بازیابی بررسی محصول
برای مشاهده بررسی محصول، از accounts.productreviews.get
استفاده کنید. این فقط خواندنی است. accountId
شما و شناسه بررسی محصول به عنوان بخشی از قسمت نام نیاز دارد. روش GET
منبع بررسی محصول مربوطه را برمی گرداند.
GET https://merchantapi.googleapis.com/reviews/v1beta/{name=accounts/{ACCOUNT_ID} /productReviews/*}
در اینجا نمونه ای وجود دارد که می توانید از آن برای بازیابی بررسی محصول استفاده کنید:
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.reviews.v1beta.GetProductReviewRequest;
import com.google.shopping.merchant.reviews.v1beta.ProductReview;
import com.google.shopping.merchant.reviews.v1beta.ProductReviewsServiceClient;
import com.google.shopping.merchant.reviews.v1beta.ProductReviewsServiceSettings;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/** This class demonstrates how to get a product review. */
public class GetProductReviewSample {
public static void getProductReview(String accountId, String productReviewId) throws Exception {
GoogleCredentials credential = new Authenticator().authenticate();
ProductReviewsServiceSettings productReviewsServiceSettings =
ProductReviewsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
try (ProductReviewsServiceClient productReviewsServiceClient =
ProductReviewsServiceClient.create(productReviewsServiceSettings)) {
GetProductReviewRequest request =
GetProductReviewRequest.newBuilder()
.setName(String.format("accounts/%s/productReviews/%s", accountId, productReviewId))
.build();
System.out.println("Sending get product review request:");
ProductReview response = productReviewsServiceClient.getProductReview(request);
System.out.println("Product review retrieved successfully:");
System.out.println(response.getName());
} catch (Exception e) {
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
String productReviewId = "YOUR_PRODUCT_REVIEW_ID";
getProductReview(config.getAccountId().toString(), productReviewId);
}
}
بررسی های محصول را لیست کنید
شما می توانید از روش productreviews.list
برای مشاهده تمام بررسی های محصول ایجاد شده استفاده کنید.
GET https://merchantapi.googleapis.com/reviews/v1beta/{parent=accounts/{ACCOUNT_ID} }/productReviews
در اینجا نمونهای وجود دارد که میتوانید از آن برای فهرست کردن تمام نظرات یک محصول استفاده کنید:
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.reviews.v1beta.ListProductReviewsRequest;
import com.google.shopping.merchant.reviews.v1beta.ProductReview;
import com.google.shopping.merchant.reviews.v1beta.ProductReviewsServiceClient;
import com.google.shopping.merchant.reviews.v1beta.ProductReviewsServiceClient.ListProductReviewsPagedResponse;
import com.google.shopping.merchant.reviews.v1beta.ProductReviewsServiceSettings;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/** This class demonstrates how to list all the product reviews in a given account. */
public class ListProductReviewsSample {
public static void listProductReviews(String accountId) throws Exception {
GoogleCredentials credential = new Authenticator().authenticate();
ProductReviewsServiceSettings productReviewsServiceSettings =
ProductReviewsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
try (ProductReviewsServiceClient productReviewsServiceClient =
ProductReviewsServiceClient.create(productReviewsServiceSettings)) {
ListProductReviewsRequest request =
ListProductReviewsRequest.newBuilder()
.setParent(String.format("accounts/%s", accountId))
.build();
System.out.println("Sending list product reviews request:");
ListProductReviewsPagedResponse response =
productReviewsServiceClient.listProductReviews(request);
int count = 0;
// Iterates over all rows in all pages and prints all product reviews.
for (ProductReview element : response.iterateAll()) {
System.out.println(element);
count++;
}
System.out.print("The following count of elements were returned: ");
System.out.println(count);
} catch (Exception e) {
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
listProductReviews(config.getAccountId().toString());
}
}
نظرات محصول را حذف کنید
برای حذف بررسی محصول، از accounts.productreviews.delete
استفاده کنید. مشابه روش GET
، این روش نیازمند فیلد نام بررسی محصول است که در حین ایجاد بازگردانده شده است.
DELETE https://merchantapi.googleapis.com/reviews/v1beta/{name=accounts/{ACCOUNT_ID} /productReviews/*}
در اینجا نمونه ای وجود دارد که می توانید از آن برای حذف بررسی محصول استفاده کنید:
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.reviews.v1beta.DeleteProductReviewRequest;
import com.google.shopping.merchant.reviews.v1beta.ProductReviewsServiceClient;
import com.google.shopping.merchant.reviews.v1beta.ProductReviewsServiceSettings;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/** This class demonstrates how to delete a product review. */
public class DeleteProductReviewSample {
public static void deleteProductReview(String accountId, String productReviewId)
throws Exception {
GoogleCredentials credential = new Authenticator().authenticate();
ProductReviewsServiceSettings productReviewsServiceSettings =
ProductReviewsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
try (ProductReviewsServiceClient productReviewsServiceClient =
ProductReviewsServiceClient.create(productReviewsServiceSettings)) {
DeleteProductReviewRequest request =
DeleteProductReviewRequest.newBuilder()
.setName(String.format("accounts/%s/productReviews/%s", accountId, productReviewId))
.build();
System.out.println("Sending delete product review request:");
productReviewsServiceClient.deleteProductReview(request);
System.out.println("Product review deleted successfully");
} catch (Exception e) {
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
String productReviewId = "YOUR_PRODUCT_REVIEW_ID";
deleteProductReview(config.getAccountId().toString(), productReviewId);
}
}
وضعیت بررسی محصول
منبع بررسی محصول دارای وضعیتی مشابه سایر APIها است که بخشی جدایی ناپذیر از منبع است و از ساختار موضوع و مقصد مشابهی پیروی می کند.