賣家評論有助消費者找到能提供優質顧客體驗的商家,進而建立信任感,做出更明智的購買決定。因此,顯示商店評分不但能改善商家的廣告和自然搜尋結果成效,還能吸引更多符合條件的顧客前往到達網頁。
本頁面說明如何使用 Merchant API 管理賣家評論。
必要條件
Google 需要你提供特定資訊。你必須具備下列條件:
- Google Merchant Center 中的有效商家評論資料來源。
- 您的帳戶必須註冊商店評分計畫。如果你不確定是否已註冊,請前往 Merchant Center 查看。如果您未註冊,請提交申請表單。
建立資料來源
使用 accounts.dataSources.create 方法建立商家評論動態饋給。如果有現有的商家評論動態饋給,請使用 accounts.dataSources.get 擷取 dataSource.name
欄位。
要求的格式如下:
POST https://merchantapi.googleapis.com/datasources/v1beta/accounts/{ACCOUNT_ID} /dataSources/{DATASOURCE_ID}
範例
以下範例顯示一般要求和回應。
要求
POST https://merchantapi.googleapis.com/datasources/v1beta/accounts/123/dataSources {"displayName": "test api feed", "merchantReviewDataSource":{} }
回應
{
"name": "accounts/123/dataSources/1000000573361824",
"dataSourceId": "1000000573361824",
"displayName": "test api feed",
"merchantReviewDataSource": {},
"input": "API"
}
詳情請參閱「商家資料來源 API 總覽」。
建立商家評論
您可以使用 accounts.merchantReviews.insert
方法建立或更新賣家評論。accounts.merchantReviews.insert
方法會將 merchantreview
資源和資料來源名稱做為輸入內容。如果成功,就會傳回新的或更新的商家評論。建立商家評論需要 datasource.name
。
要求的格式:
POST https://merchantapi.googleapis.com/reviews/v1beta/{parent=accounts/*/}merchantReviews:insert
請參考下列商家評論範例。
POST https://merchantapi.googleapis.com/reviews/v1beta/accounts/{ACCOUNT_ID} /merchantReviews:insert?dataSource=accounts/{ACCOUNT_ID} /dataSources/{DATASOURCE_ID}
merchantReviewId = 'my_own_review'
attributes {
merchantId = 'merchant_id'
merchantDisplayName = 'merchant_display_name'
merchantLink = 'publisher_name'
merchantRatingLink = 'https://www.google.com'
minRating = 1
maxRating = 10
rating = 7.9
title = 'Amazing Merchant'
content = 'This is an incredible merchant'
reviewerId = 'reviewer_id'
reviewerUsername = 'reviewer_username'
isAnonymous = false
collectionMethod = 'AFTER_FULFILLMENT'
reviewTime = '2024-04-01T00:00:00Z'
reviewLanguage = 'en'
reviewCountry = 'US'
}
商家評論建立後,可能需要幾分鐘的時間才能傳播。
查看商家評論
如要查看商家評論,請使用 accounts.merchantReviews.get
。這是唯讀欄位。請在名稱欄位中提供您的 merchantId
和商家評論 ID。get 方法會傳回對應的商家評論資源。
例如:
GET https://merchantapi.googleapis.com/reviews/v1beta/{name=accounts/*/merchantReviews/*}
如要擷取特定 Merchant Center 帳戶的單一產品,可以使用 google.shopping.merchant.accounts.v1beta.GetProductRequest
方法,如以下範例所示。
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.products.v1beta.GetProductRequest;
import com.google.shopping.merchant.products.v1beta.Product;
import com.google.shopping.merchant.products.v1beta.ProductsServiceClient;
import com.google.shopping.merchant.products.v1beta.ProductsServiceSettings;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/** This class demonstrates how to get a single product for a given Merchant Center account */
public class GetProductSample {
public static void getProduct(Config config, String product) throws Exception {
// Obtains OAuth token based on the user's configuration.
GoogleCredentials credential = new Authenticator().authenticate();
// Creates service settings using the credentials retrieved above.
ProductsServiceSettings productsServiceSettings =
ProductsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
// Calls the API and catches and prints any network failures/errors.
try (ProductsServiceClient productsServiceClient =
ProductsServiceClient.create(productsServiceSettings)) {
// The name has the format: accounts/{account}/products/{productId}
GetProductRequest request = GetProductRequest.newBuilder().setName(product).build();
System.out.println("Sending get product request:");
Product response = productsServiceClient.getProduct(request);
System.out.println("Retrieved Product below");
System.out.println(response);
} catch (Exception e) {
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
// The name of the `product`, returned after a `Product.insert` request. We recommend
// having stored this value in your database to use for all future requests.
String product = "accounts/{datasource}/products/{productId}";
getProduct(config, product);
}
}
列出商家評論
您可以使用 accounts.merchantReviews.list
方法查看所有已建立的商家評論。
GET https://merchantapi.googleapis.com/reviews/v1beta/accounts/{ACCOUNT_ID} /merchantReviews
刪除商家評論
如要刪除商家評論,請使用 accounts.merchantReviews.delete
。與 accounts.merchantReviews.get
方法類似,這個方法需要商家評論建立期間傳回的商家評論名稱欄位。
例如:
DELETE https://merchantapi.googleapis.com/reviews/v1beta/{name=accounts/*/merchantReviews/*}
商家審查狀態
商家審查資源包含的狀態與其他 API 類似,是資源的必要部分,並遵循相同的問題和目的地結構。