直接在自家平台上提供商家資訊管理服務的供應商,可以在其網站中驗證商家。這樣就不必將商家重新導向至商家檔案 UI。
取得目前狀態
使用者可以針對位置呼叫 locations.getVoiceOfMerchantState
,擷取目前的狀態。如果 hasVoiceOfMerchant
布林值為 true
,表示地點記錄良好,因此不必採取其他行動。否則,如果回應中的 gain_voice_of_merchant
動作包含 verify
,您就必須完成驗證。詳情請參閱下方說明。
擷取驗證選項
供應商可以使用 locations.fetchVerificationOptions
方法,提示商家從可用的驗證方法清單中選擇偏好的聯絡方式。
如要擷取驗證選項,請使用下列程式碼:
POST https://mybusinessverifications.googleapis.com/v1/{locationId}:fetchVerificationOptions { "languageCode": "en" }
啟動驗證程序
選擇驗證方法後,請透過 locations.verify
啟動驗證程序。透過此呼叫,地點會移至已驗證狀態,或者傳回錯誤狀態。
POST https://mybusinessverifications.googleapis.com/v1/locations/{locationId} :verify // Use only one of the below verification methods // For postcard verification: { "method": "ADDRESS", "languageCode": "en", "addressInput": { "mailerContactName": "Ann Droyd" } } // For phone verification: { "method": "PHONE_CALL", "languageCode": "en", "phoneInput": { "phoneNumber": "800-555-0136" } } // For SMS verification: { "method": "SMS", "languageCode": "en", "phoneInput": { "phoneNumber": "800-555-0136" } } // For email verification: { "method": "EMAIL", "languageCode": "en", "emailInput": { "emailAddress": "ex@google.com" } }
擷取目前的驗證作業
locations.verifications.list
呼叫會擷取驗證要求的記錄,以及呼叫中指定地點的狀態。
如要擷取所有驗證要求,請使用下列程式碼:
GET https://mybusinessverifications.googleapis.com/v1/locations/{locationId} /verifications
完成待處理的驗證
商家通常需要 PIN 碼和 locations.verifications.complete
方法,才能完成驗證程序。
如要完成待處理的驗證,請使用下列方法:
POST https://mybusinessverifications.googleapis.com/v1/locations/{locationId} /verifications/{verificationId}:complete { "pin": "123456" }
使用 API 驗證 Google 商家檔案的最佳做法
建立位置
您可以使用 GBP Business Information API 來嵌入平台,藉此提供地點建立功能。要求商家新增地點時,請務必遵循以下步驟:
收集商家的位置資訊,例如商家名稱、地址、類別。
- 呼叫
googleLocations.search
端點。 - 在 API 要求中提供位置資料,例如商家名稱、類別、地址、電話號碼和網站。
或者,您也可以按照以下步驟,搜尋可能相符的位置:
- 查詢可能的位置相符。
- 請商家選擇正確的地點。
- 如果地點回應中含有「
requestAdminRightsUrl
」,請協助商家在 Google 商家檔案上要求該地點的存取權和擁有權。 - 如果
requestAdminRightsUrl
不存在,請使用位置回應中的地點 ID 建立新地點。 - 驗證新的位置。
注意:如果您在初始查詢中找不到任何可能相符的地點,請使用空白的地點 ID 來建立新地點。然後驗證新地點。
地點驗證
如要使用 GBP API 進行驗證,請按照下列步驟操作:
- 呼叫
accounts.locations.list
方法,列出某個 Google 帳戶的所有地點。 - 選取要驗證的地點。
- 呼叫
GetVoiceOfMerchant
API 方法,確認該位置是否需要驗證。 - 如果回應傳回驗證,請呼叫
fetchVerificationOptions
來取得可用於驗證該位置的方法清單。 - 仔細檢查
verificationOption
資料是否包含正確的地址、電話號碼和電子郵件地址。 - 機制選取最適當的驗證選項後,請呼叫
locations.verify
方法,啟動適當的驗證程序。如要確認啟動中,請呼叫locations.verifications.list.
- 使用商家 PIN 碼呼叫
locations.verification.complete
方法。 - 呼叫
GetVoiceOfMerchant
API 方法。如果HasVoiceOfMerchant = true
,就表示你已成功驗證位置。
注意:如果該地點適用「AUTO
」驗證,則商家不需要執行任何驗證步驟
如要進一步瞭解 Google 商家檔案驗證,請參閱說明中心文章。