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

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

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

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

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

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

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

כדי ליצור מקור נתונים של ביקורות על מוצרים, צריך להשתמש ב-method‏ accounts.dataSources.create. אם יש מקור נתונים קיים של ביקורות על מוֹכר, משתמשים ב-method‏ 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'
  }

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

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

כדי לראות ביקורת על מוכר, משתמשים ב-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 void 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();

    // 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}
      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);
    } catch (Exception e) {
      System.out.println(e);
    }
  }

  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~US~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, השיטה הזו דורשת את שדה השם של ביקורת המוצר של המוכר שמוחזר במהלך היצירה.

לדוגמה:

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

סטטוס הביקורת על המוֹכר

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