商家信息

获取高级、语音和重复的目录商家信息,管理重复商家信息的屏蔽,并使用 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

将某个地点的一个或多个商家信息条目标记为重复。平台将尝试屏蔽已标记的商家资料。

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');}