รีวิวผู้ขายช่วยให้ผู้คนค้นพบธุรกิจที่มอบประสบการณ์ของลูกค้าคุณภาพสูง ซึ่งจะสร้างความน่าเชื่อถือและช่วยให้ลูกค้ามีข้อมูลประกอบการตัดสินใจซื้อมากขึ้น ด้วยเหตุนี้ คะแนนร้านค้าจึงช่วยให้ธุรกิจปรับปรุงประสิทธิภาพของโฆษณาและข้อมูลทั่วไป รวมถึงดึงดูดลูกค้าที่เข้าเกณฑ์ไปยังหน้า Landing Page ได้มากขึ้น
หน้านี้อธิบายวิธีจัดการรีวิวผู้ขายโดยใช้ Merchant API
ข้อกำหนดเบื้องต้น
Google ต้องการให้คุณระบุข้อมูลที่เฉพาะเจาะจง คุณต้องมีสิ่งต่อไปนี้
- แหล่งข้อมูลรีวิวผู้ขายที่ใช้งานอยู่ใน Google Merchant Center
- บัญชีของคุณต้องลงทะเบียนในโปรแกรมคะแนนร้านค้า หากไม่แน่ใจว่าลงทะเบียนแล้วหรือไม่ ให้ตรวจสอบ Merchant Center หากยังไม่ได้ลงทะเบียน ให้ส่งแบบฟอร์มคำขอ
สร้างแหล่งข้อมูล
ใช้เมธอด accounts.dataSources.create เพื่อสร้างแหล่งข้อมูลรีวิวจากผู้ขาย หากมีแหล่งข้อมูลรีวิวของผู้ขายอยู่แล้ว ให้ใช้ accounts.dataSources.list เพื่อดึงข้อมูลช่อง accounts.dataSources.name
หากต้องการอ้างอิงแหล่งข้อมูลโดยตรงในการเรียก API ในอนาคต เราขอแนะนำให้คุณจัดเก็บ accounts.dataSources.name สำหรับแหล่งข้อมูลที่สร้างไว้ในฐานข้อมูลในเครื่องเพื่อให้ผู้ขายตรวจสอบ สำหรับแหล่งข้อมูลที่มีอยู่ ให้ทำการทดแทนข้อมูลในฐานข้อมูลในเครื่องด้วยชื่อของแหล่งข้อมูลดังกล่าวเพียงครั้งเดียว
รูปแบบของคำขอมีดังนี้
POST https://merchantapi.googleapis.com/datasources/v1/accounts/{ACCOUNT_ID}/dataSources/{DATASOURCE_ID}
ตัวอย่าง
ตัวอย่างแสดงคำขอและการตอบกลับทั่วไป
คำขอ
POST https://merchantapi.googleapis.com/datasources/v1/accounts/123/dataSources {"displayName": "test api data source", "merchantReviewDataSource":{} }
คำตอบ
{
"name": "accounts/123/dataSources/1000000573361824",
"dataSourceId": "1000000573361824",
"displayName": "test api data source",
"merchantReviewDataSource": {},
"input": "API"
}
ดูข้อมูลเพิ่มเติมได้ที่สร้างแหล่งข้อมูลรีวิวสินค้า
สร้างรีวิวผู้ขาย
คุณสามารถใช้เมธอด accounts.merchantReviews.insert เพื่อสร้างหรืออัปเดตรีวิวผู้ขายได้ เมธอด accounts.merchantReviews.insert จะใช้ทรัพยากร merchantreview และชื่อแหล่งข้อมูลเป็นอินพุต ระบบจะแสดงรีวิวผู้ขายใหม่หรือที่อัปเดตแล้วหากดำเนินการสำเร็จ การสร้างรีวิวผู้ขายต้องใช้ accounts.dataSources.name
รูปแบบของคำขอ:
POST https://merchantapi.googleapis.com/reviews/v1alpha/{parent=accounts/*/}merchantReviews:insert
ศึกษาตัวอย่างรีวิวผู้ขายต่อไปนี้เพื่อใช้เป็นข้อมูลอ้างอิง
POST https://merchantapi.googleapis.com/reviews/v1alpha/accounts/{ACCOUNT_ID}/merchantReviews:insert?dataSource=accounts/{ACCOUNT_ID}/dataSources/{DATASOURCE_ID}
merchantReviewId = 'my_own_review'
merchantReviewAttributes {
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'
}
หลังจากสร้างรีวิวผู้ขายแล้ว ระบบอาจใช้เวลา 2-3 นาทีในการเผยแพร่รีวิว
ดูรีวิวผู้ขาย
หากต้องการดูรีวิวผู้ขาย ให้ใช้ accounts.merchantReviews.get
ซึ่งเป็นแบบอ่านอย่างเดียว โดยต้องระบุ merchantId และรหัสของรีวิวผู้ขายเป็นส่วนหนึ่งของช่องชื่อ เมธอด get จะแสดงผลทรัพยากรรีวิวของผู้ขายที่เกี่ยวข้อง
เช่น
GET https://merchantapi.googleapis.com/reviews/v1alpha/{name=accounts/*/merchantReviews/*}
หากต้องการดึงข้อมูลผลิตภัณฑ์รายการเดียวสำหรับบัญชี Merchant Center ที่ระบุ คุณสามารถใช้เมธอด google.shopping.merchant.accounts.v1.GetProductRequest ดังที่แสดงในตัวอย่างต่อไปนี้
Java
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.common.io.BaseEncoding;
import com.google.shopping.merchant.products.v1.GetProductRequest;
import com.google.shopping.merchant.products.v1.Product;
import com.google.shopping.merchant.products.v1.ProductsServiceClient;
import com.google.shopping.merchant.products.v1.ProductsServiceSettings;
import java.nio.charset.StandardCharsets;
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 {
// Base64Url encoder/decoder without padding
private static final BaseEncoding BASE64URL_NOPADDING = BaseEncoding.base64Url().omitPadding();
// Encodes a string to base64url without padding
public static String encodeProductId(String productId) {
return BASE64URL_NOPADDING.encode(productId.getBytes(StandardCharsets.UTF_8));
}
public static Product getProduct(Config config, String accountId, String productId)
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();
try (ProductsServiceClient productsServiceClient =
ProductsServiceClient.create(productsServiceSettings)) {
// The name has the format: accounts/{account}/products/{productId}
String name = "accounts/" + accountId + "/products/" + productId;
// The name has the format: accounts/{account}/products/{productId}
GetProductRequest request = GetProductRequest.newBuilder().setName(name).build();
System.out.println("Sending get product request:");
Product response = productsServiceClient.getProduct(request);
System.out.println("Retrieved Product below");
System.out.println(response);
return response;
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
String accountId = config.getAccountId().toString();
// 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 productId = "en~GB~sku123"; // Replace with your actual product ID
// Uncomment the following line if the product name contains special characters (such as forward
// slashes) and needs base64url encoding.
// productId = encodeProductId(productId);
getProduct(config, accountId, productId);
}
}
แสดงรีวิวผู้ขาย
คุณสามารถใช้เมธอด accounts.merchantReviews.list เพื่อดูรีวิวจากผู้ขายทั้งหมดที่สร้างขึ้นได้
GET https://merchantapi.googleapis.com/reviews/v1alpha/accounts/{ACCOUNT_ID}/merchantReviews
ลบรีวิวผู้ขาย
หากต้องการลบรีวิวของผู้ขาย ให้ใช้ accounts.merchantReviews.delete
วิธีนี้คล้ายกับวิธี accounts.merchantReviews.get ตรงที่ต้องใช้ช่อง name ของรีวิวผู้ขายที่แสดงผลระหว่างการสร้าง
เช่น
DELETE https://merchantapi.googleapis.com/reviews/v1alpha/{name=accounts/*/merchantReviews/*}
สถานะรีวิวผู้ขาย
แหล่งข้อมูลรีวิวของผู้ขายมีสถานะคล้ายกับ API อื่นๆ ซึ่งเป็นส่วนสำคัญของแหล่งข้อมูลและเป็นไปตามโครงสร้างปัญหาและปลายทางเดียวกัน