[英]Google My business API locations list request not returning all locations
我正在向 Google 我的商家 API 发出位置列表请求并传递给定的帐户 ID。 list 方法应该返回与给定 id 关联的所有位置的列表。 可以在此处找到文档https://developers.google.com/my-business/reference/rest/v4/accounts.locations/list 。 响应按预期返回位置列表,但是列表中缺少该帐户可以访问的某些位置。 我试图调查是否有任何因素可能导致这种情况,例如验证状态、缺少商店代码、重复的 GMB 位置、谁拥有/管理该位置。 我还没有发现任何导致问题的因素。 任何人有任何见解?
最大页面大小为 100 [1][2]。 您是否期望单个请求超过 100 个?
[1] https://developers.google.com/my-business/reference/rest/v4/accounts.locations/list
[2] https://developers.google.com/my-business/reference/businessinformation/rest/v1/accounts.locations/list
这个 API 有一个更新版本叫做mybusinessbusinessinformation
,如果你使用编程语言来检索你列出所有位置就不会有任何问题,例如在 java 中,假设mybusinessNotif
是MyBusinessNotificationSettings
类型的初始化程序,它也负责证书:
String readMask="storeCode,regularHours,name,languageCode,title,phoneNumbers,categories,storefrontAddress,websiteUri,regularHours,specialHours,serviceArea,labels,adWordsLocationExtensions,latlng,openInfo,metadata,profile,relationshipData,moreHours";
MyBusinessBusinessInformation.Accounts.Locations.List locationsList = mybusinessaccountLocations.accounts().locations().list(accountName).setReadMask(readMask);
ListLocationsResponse Response = locationsList.execute();
locations=Response.getLocations();
while (Response.getNextPageToken() != null) {
locationsList.setPageToken(Response.getNextPageToken());
Response=locationsList.execute();
locations.addAll(Response.getLocations());
}
事实上,使用getNextPageToken()
可以解决您的问题。
我在 Node.js 环境中遇到了类似的问题。
Google 商家资料 Api 方法:accounts.locations.list
虽然文档中Query Parameters下pageSize默认设置为100,但是如果你在请求的时候没有定义pageSize,最多可以获得10个位置。 我能够通过定义一个可选的 pageSize 来解决我的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.