نقد و بررسی محصولات بخش مهمی از تجربه خرید مشتریان است. این رتبهبندیها و نقد و بررسیها به مشتریان در تحقیق در مورد محصول و تصمیمگیری برای خرید کمک میکنند. نقد و بررسیهای مثبت محصولات میتواند مشتریان واجد شرایط بیشتری را به صفحات محصول فروشنده هدایت کند. منابع این نقد و بررسیها شامل فروشندگان، جمعآوریکنندگان نقد و بررسی، سایتهای نقد و بررسی و کاربران گوگل میشود.
این صفحه توضیح میدهد که چگونه میتوانید با استفاده از Merchant API، نظرات مربوط به محصولات را مدیریت کنید.
پیشنیازها
گوگل از شما میخواهد اطلاعات خاصی را ارائه دهید. شما باید موارد زیر را داشته باشید:
- یک فید فعال برای بررسی محصول در مرکز فروشندگان گوگل.
- حساب شما باید در برنامه رتبهبندی محصولات ثبت شده باشد. اگر مطمئن نیستید که قبلاً ثبت نام کردهاید یا خیر، مرکز فروشندگان را بررسی کنید. اگر ثبت نام نکردهاید، درباره ثبت نام در برنامه رتبهبندی محصولات بیشتر بدانید.
- برای بررسی محصولات با استفاده از Merchant API، درخواستی را با استفاده از این فرم ارسال کنید.
ایجاد منبع داده
از API datasource.create برای ایجاد یک فید نقد و بررسی محصول استفاده کنید. اگر فید نقد و بررسی محصول موجود است، 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"
}
برای اطلاعات بیشتر، به ایجاد منبع داده بررسی محصول مراجعه کنید.
ایجاد نقد و بررسی محصول
شما میتوانید از متد accounts.productreviews.insert برای ایجاد یا بهروزرسانی یک نقد و بررسی محصول استفاده کنید. متد accounts.productreviews.insert یک منبع productreview و یک نام منبع داده را به عنوان ورودی دریافت میکند. در صورت موفقیت، نقد productreview جدید یا بهروزرسانی شده را برمیگرداند. برای ایجاد یک نقد و بررسی محصول، باید یک datasource.name داشته باشید.
فرم درخواست:
POST https://merchantapi.googleapis.com/reviews/v1alpha/{parent=accounts/{ACCOUNT_ID}/}productReviews:insert
نمونه درخواست زیر نحوه ایجاد یک بررسی محصول را نشان میدهد.
POST https://merchantapi.googleapis.com/reviews/v1alpha/accounts/{ACCOUNT_ID}/productReviews:insert?dataSource=accounts/{ACCOUNT_ID}/dataSources/{DATASOURCE_ID}
productReviewId = 'my_product_review'
productReviewAttributes {
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/v1/{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/v1/{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/v1/{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ها است که بخش جداییناپذیری از منبع است و از همان ساختار مسئله و مقصد پیروی میکند.