本教學課程將說明如何在商家檔案中擷取位置指標。Google My Business API 可讓您使用位置指標,擷取下列類型的資料:
事前準備
使用 Google 我的商家 API 前,您必須註冊應用程式並取得 OAuth 2.0 憑證。如要進一步瞭解如何開始使用 Google My Business API,請參閱「基本設定」。
支援的洞察資料
如要瞭解支援的洞察資料,請參閱「指標」參考頁面。
基本洞察
針對指定的地點清單擷取基本洞察資料。使用 accounts.locations.reportInsights
API 傳回與位置相關的洞察資料。
如要傳回與地點相關的基本洞察資料,請使用以下指令:
POST https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations:reportInsights { "locationNames": [ "accounts/{accountId}/locations/{locationId}" ], "basicRequest": { "metricRequests": [ { "metric": "QUERIES_DIRECT" }, { "metric": "QUERIES_INDIRECT" } ], "timeRange": { "startTime": "2016-10-12T01:01:23.045123456Z", "endTime": "2017-01-10T23:59:59.045123456Z" } } }
行車路線
擷取指定位置清單的駕車路線指標。使用 accounts.locations.reportInsights
API 傳回與位置相關聯的駕駛路線指標。
如要傳回駕駛方向指標,請使用下列指令:
POST https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations:reportInsights { "locationNames": [ "accounts/{accountId}/locations/{locationId}" ], "drivingDirectionsRequest": { "numDays": "NINETY" } }