我尝试订阅每次使用以下代码为企业发布新评价时都会收到通知。
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();
}
当我尝试执行代码时,我收到以下错误。
com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
"code" : 400,
"errors" : [ {
"domain" : "global",
"message" : "Request contains an invalid argument.",
"reason" : "badRequest"
} ],
"message" : "Request contains an invalid argument.",
"status" : "INVALID_ARGUMENT"
}
有人可以告诉我我做错了吗?
- 编辑 -
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();
}
答案 0 :(得分:1)
Notifications
要求设置notificationTypes
和name
。 let numDoubled = num + (noise ? weighting : 0.0)
字段将被忽略。见https://developers.google.com/my-business/reference/rest/v4/Notifications