בדיקת מוכרים באמצעות Merchant API

ביקורות על אתרי מכירה עוזרות לאנשים למצוא עסקים שמציעים חוויית לקוח (CX) איכותית, וכך בונות אמון ומאפשרות לקבל החלטות מושכלות יותר בנוגע לרכישות. כתוצאה מכך, דירוגי חנויות יכולים לעזור לעסקים לשפר את הביצועים של מודעות ושל כרטיסי מוצר אורגניים ולמשוך יותר לקוחות מתאימים לדפי הנחיתה שלהם.

בדף הזה מוסבר איך לנהל ביקורות על אתר המכירה באמצעות Merchant API.

דרישות מוקדמות

‫Google צריכה שתספקו מידע ספציפי. אתם צריכים:

  • מקור נתונים פעיל של ביקורות על מוכרים ב-Google Merchant Center.
  • החשבון שלכם צריך להיות רשום לתוכנית דירוגי החנות. אם אתם לא בטוחים אם כבר נרשמתם, אתם יכולים לבדוק את זה ב-Merchant Center. אם אתם לא רשומים, שלחו את טופס הבקשה.

יצירת מקור נתונים

כדי ליצור מקור נתונים של ביקורות על העסק, משתמשים ב-method‏ 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"
}

מידע נוסף על יצירת מקור נתונים של ביקורות על מוצרים

יצירת ביקורת על המוכר

אתם יכולים להשתמש ב-method‏ accounts.merchantReviews.insert כדי ליצור או לעדכן ביקורת על אתר מכירה. ה-method ‏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'
  }

אחרי שיוצרים ביקורת על מוכר, יכול להיות שיעברו כמה דקות עד שהיא תתעדכן.

צפייה בביקורות על המוכר

כדי לראות ביקורת על מוכר, משתמשים ב-accounts.merchantReviews.get. הוא לקריאה בלבד. כדי להשתמש בה, צריך לציין את merchantId ואת המזהה של ביקורת המוכר בשדה השם. שיטת אחזור הנתונים מחזירה את המשאב המתאים של ביקורת על המוכר.

לדוגמה:

GET https://merchantapi.googleapis.com/reviews/v1alpha/{name=accounts/*/merchantReviews/*}

כדי לאחזר מוצר אחד מחשבון Merchant Center מסוים, אפשר להשתמש ב-method‏ 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. בדומה ל-method‏ accounts.merchantReviews.get, גם ב-method הזה צריך לציין את השדה name של הביקורת על המוכר שהוחזר במהלך היצירה.

לדוגמה:

DELETE https://merchantapi.googleapis.com/reviews/v1alpha/{name=accounts/*/merchantReviews/*}

סטטוס הבדיקה של המוכר

המשאב של ביקורת על המוכר מכיל את הסטטוס בדומה לממשקי API אחרים, שהוא חלק בלתי נפרד מהמשאב ופועל לפי אותו מבנה של בעיה ויעד.