Java Google Business Api-发布子更新通知设置
我正在尝试订阅,以便在每次使用以下代码发布新的业务评论时收到通知Java Google Business Api-发布子更新通知设置,java,google-cloud-pubsub,google-client,google-my-business-api,Java,Google Cloud Pubsub,Google Client,Google My Business Api,我正在尝试订阅,以便在每次使用以下代码发布新的业务评论时收到通知 private static final String topicName = "projects/myproject-12345/topics/business-review"; MyBusiness myBusiness = GMBFactory.getMyBusiness(); MyBusiness.Accounts.List accountsList = myBusiness.accounts().list();
private static final String topicName = "projects/myproject-12345/topics/business-review";
MyBusiness myBusiness = GMBFactory.getMyBusiness();
MyBusiness.Accounts.List accountsList = myBusiness.accounts().list();
ListAccountsResponse response = accountsList.execute();
List<Account> accounts = response.getAccounts();
for (Account account : accounts) {
Notifications notification = new Notifications().setName(topicName);
UpdateNotifications updateNotification = myBusiness.accounts().updateNotifications(account.getName() + "/notifications",
notification);
updateNotification.execute();
}
有人能告诉我我做错了什么吗
-编辑-
MyBusiness myBusiness = GMBFactory.getMyBusiness();
MyBusiness.Accounts.List accountsList = myBusiness.accounts().list();
ListAccountsResponse response = accountsList.execute();
List<Account> accounts = response.getAccounts();
for (Account account : accounts) {
Notifications notification = new Notifications();
notification.setTopicName(topicName);
notification.setName("review");
UpdateNotifications updateNotification = myBusiness.accounts().updateNotifications(account.getName() + "/notifications",
notification);
updateNotification.execute();
}
需要设置topicName和notificationTypes。名称字段将被忽略。请参见我已设置了名称和主题名称,但仍然收到相同的错误。请尝试设置notificationTypes
MyBusiness myBusiness = GMBFactory.getMyBusiness();
MyBusiness.Accounts.List accountsList = myBusiness.accounts().list();
ListAccountsResponse response = accountsList.execute();
List<Account> accounts = response.getAccounts();
for (Account account : accounts) {
Notifications notification = new Notifications();
notification.setTopicName(topicName);
notification.setName("review");
UpdateNotifications updateNotification = myBusiness.accounts().updateNotifications(account.getName() + "/notifications",
notification);
updateNotification.execute();
}