Merchant API を使用して販売者を確認する

販売者レビューによって、ユーザーは質の高いカスタマー エクスペリエンスを提供しているビジネスを見つけ、そのビジネスへの信頼を高め、十分な情報に基づいて購入を判断できます。その結果、ショップの評価は、広告とオーガニック リスティングのパフォーマンスを高め、より多くの有望な見込み顧客をランディング ページに誘導するのに役立ちます。

このページでは、Merchant API を使用して販売者のレビューを管理する方法について説明します。

前提条件

そのためには、お客様から具体的な情報をご提供いただく必要があります。次の要件を満たしている必要があります。

  • 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"
}

詳しくは、Merchant Data sources 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 メソッドを使用します。

Java
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 と同様のステータスが含まれます。これはリソースの不可欠な部分であり、同じ問題と宛先の構造に従います。