管理即時通知

在 My Business Notifications API 中,系統會發布通知至 Cloud Pub/Sub 服務。設定 Cloud Pub/Sub 並建立主題後,您可以對通知執行下列作業:

支援新或更新的評論、問題與解答、媒體上傳、評論 Google 更新、位置狀態變更等。NotificationType 物件清單,會說明可用的通知類型。

事前準備

如要使用 My Business Notifications API,請註冊應用程式並取得 OAuth 2.0 憑證。如要進一步瞭解如何開始使用 API,請參閱基本設定

Cloud Pub/Sub 設定

如要透過 Cloud Pub/Sub 設定 API 通知,請執行下列步驟:

  1. 按照 Cloud Pub/Sub 指南的說明設定應用程式
  2. 在您的 Cloud Pub/Sub 專案中建立主題,並記下已建立主題的名稱。
  3. 至少將 pubsub.topics.publish 權限授予 mybusiness-api-pubsub@system.gserviceaccount.com。
  4. 請按照訂閱者總覽指南來設定推送或提取通知。
  5. 如要接收通知,請在 My Business Notifications API 中呼叫 accounts.updateNotificationSetting 端點。在通話中,請使用您在 Cloud Pub/Sub 建立的主題名稱,將商家檔案帳戶連結至該主題。
  6. (選用) 請針對要接收通知的每個商家檔案帳戶重複步驟 5。

擷取通知設定

accounts.getNotificationSetting 端點會傳回帳戶目前的 Cloud Pub/Sub 通知設定。下表顯示如何呼叫此函式:

HTTP
GET
https://mybusinessnotifications.googleapis.com/v1/accounts/{accountId}/notificationSetting

更新通知設定

accounts.updateNotificationSetting 端點會更新與某個帳戶相關聯的 Cloud Pub/Sub 通知設定。下表顯示如何呼叫此函式:

HTTP
PATCH
https://mybusinessnotifications.googleapis.com/v1/accounts/{accountId}/notificationSetting?updateMask={commaSeparatedFieldsToUpdate}

{
  pubsubTopic: your/pubsub/topicName
}

刪除通知設定

以空白 pubsubTopic 呼叫 accounts.updateNotificationSetting 會從帳戶中刪除 Cloud Pub/Sub 通知設定。下表顯示如何呼叫此函式:

HTTP
PATCH
https://mybusinessnotifications.googleapis.com/v1/accounts/{accountId}/notificationSetting?updateMask=pubsubTopic