商家資訊

取得付費、語音及重複的目錄商家資訊,管理重複商家資訊的抑制功能,並使用 listingsapi-js SDK 連結商家檔案。

商家資訊代表地點在各個目錄(Google、Yelp、Bing、Alexa、Siri 等)上的資料。所有商家資訊方法都位於 ListingsAPI 用戶端實例上,且操作範圍限定於指定的地點 ID。數字形式的地點 ID 會自動編碼,因此 16808 和 'TG9jYXRpb246MTY4MDg=' 可以互換使用。

fetchPremiumListings

取得地點在進階目錄中的商家資訊,包括 Google、Yelp、Facebook,以及核心目錄網路中的其他目錄。傳回由 Listing 物件組成的陣列,物件包含 id、site、syncStatus、displayStatus 和 listingUrl 等欄位。

TypeScript
const listings = await client.fetchPremiumListings(16808); for (const l of listings) {console.log(l.site, l.syncStatus, l.listingUrl);}

syncStatus 的可能值包括 SYNCED、PENDING、ERROR 和 NOT_CONNECTED。

fetchVoiceListings

取得語音助理上的商家資訊,包括 Google Assistant、Amazon Alexa、Apple Siri 及類似的助理。傳回由 VoiceListing 物件組成的陣列,物件包含 name、voiceIdentifier 和 syncStatus 等欄位。

TypeScript
const voice = await client.fetchVoiceListings(16808); console.log(voice.length + ' voice listings');for (const v of voice) {console.log(v.name, v.syncStatus);}

fetchDuplicateListings

取得針對特定地點偵測到的重複商家資訊。傳回由 DuplicateListing 物件組成的陣列,物件包含 id、site 和 listingUrl 等欄位。

TypeScript
const duplicates = await client.fetchDuplicateListings(16808); for (const d of duplicates) {console.log(d.site, d.listingUrl);}

fetchAllDuplicateListings

取得帳戶內所有地點的重複商家資訊彙總,可選擇依標籤篩選及使用分頁。與 fetchDuplicateListings 不同,此方法傳回彙總物件,而非一般陣列。

TypeScript
// All duplicates across the accountconst rollup = await client.fetchAllDuplicateListings(); // Filter by tag and pageconst page2 = await client.fetchAllDuplicateListings({ tag: 'region:west', page: 2 });

選項

參數型別說明
tagstring僅包含帶有此標籤的地點。
pagenumber頁碼(從 1 開始)。

markListingsAsDuplicate

將某個地點的 1 個或多個商家資訊項目標記為重複。平台會嘗試隱藏已標記的商家檔案。

TypeScript
await client.markListingsAsDuplicate(16808, ['listing-item-id-1','listing-item-id-2',]);

參數

參數型別說明
locationIdstring | number商家資訊項目所屬的地點。
listingItemIdsstring[]要標記的商家資訊項目 ID。

沒有可供檢查的成功旗標。如果平台拒絕寫入,用戶端會擲回 ValidationError,因此 promise 成功完成即表示操作成功。

markListingsAsNotDuplicate

清除誤標商家資訊項目的重複旗標。

TypeScript
await client.markListingsAsNotDuplicate(16808, ['listing-item-id-1',]);

參數

參數型別說明
locationIdstring | number商家資訊項目所屬的地點。
listingItemIdsstring[]要清除旗標的商家資訊項目 ID。

connectListing

將地點連結至已連線的 Google 或 Facebook 帳戶中的商家資訊。請在連線帳戶並找到相符的商家資訊後使用此方法。

TypeScript
await client.connectListing(16808,'connected-listing-id','connected-account-id',);

參數

參數型別說明
locationIdstring | number要連結的地點。
connectedAccountListingIdstring已連線帳戶中的商家資訊 ID。
connectedAccountIdstring已連線的 Google 或 Facebook 帳戶 ID。

disconnectListing

解除地點與其 Google 或 Facebook 商家資訊的連結。網站名稱會自動轉為大寫,因此 'google' 和 'GOOGLE' 都可以使用。

TypeScript
await client.disconnectListing(16808, 'GOOGLE');

參數

參數型別說明
locationIdstring | number要解除連結的地點。
sitestring要中斷連線的目錄,例如 'GOOGLE' 或 'FACEBOOK'。

createGmbListing

使用已連線的 Google 帳戶,為現有地點建立 Google Business Profile 商家資訊。

TypeScript
const result = await client.createGmbListing(16808, 'connected-account-id'); // Optionally place the new listing in a specific folderawait client.createGmbListing(16808, 'connected-account-id', {folderId: 'folder-id',});

參數

參數型別說明
locationIdstring | number要為其建立商家資訊的地點。
connectedAccountIdstring已連線的 Google 帳戶 ID。
options.folderIdstring用於建立商家資訊的資料夾,可省略。

典型稽核流程

listings_audit.ts
import { ListingsAPI } from 'listingsapi-js'; const client = new ListingsAPI(); // reads LISTINGSAPI_KEY from envconst LOCATION_ID = 16808; // Acme Dental const [premium, duplicates] = await Promise.all([client.fetchPremiumListings(LOCATION_ID),client.fetchDuplicateListings(LOCATION_ID),]); const unsynced = premium.filter((l) => l.syncStatus !== 'SYNCED');console.log(unsynced.length + ' unsynced listings'); if (duplicates.length > 0) {const ids = duplicates  .map((d) => d.id)  .filter((id): id is string => Boolean(id));await client.markListingsAsDuplicate(LOCATION_ID, ids);console.log('Marked ' + ids.length + ' duplicates');}