我正在尝试twilio服务并发送通知正常但我无法正确设置短信回退,因为这并没有真正记录。
HashMap<String, Object> smsNumbers = new HashMap<>();
smsNumbers.put("?", "?");
LOGGER.debug("Adding SMS fallback to: {}", smsNumbers);
LOGGER.debug("Calling sendNotification to {}", identity);
Notification notification = Notification
.creator(twilioServiceSid)
.setBody(message)
.setData(data)
.setIdentity(identity)
.setSms(smsNumbers)
.create(restClient);
我收到以下错误:
com.twilio.exception.ApiException: Parameter 'Sms' contains unrecognized property.
at com.twilio.rest.notify.v1.service.NotificationCreator.create(NotificationCreator.java:316) [twilio-7.15.1.jar:]
如何填写HashMap?
答案 0 :(得分:0)
Twilio开发者传道者在这里。
设置将通过短信渠道从通知发送的数据时,您可以设置以下任意键来覆盖常规通知:body
,media_urls
,status_callback
和max_price
。
因此,如果您想通过SMS发送替代正文,则可以使用以下代码:
HashMap<String, Object> smsNumbers = new HashMap<>();
smsNumbers.put("body", "This is just for the SMS notifications");
LOGGER.debug("Adding SMS fallback to: {}", smsNumbers);
LOGGER.debug("Calling sendNotification to {}", identity);
Notification notification = Notification
.creator(twilioServiceSid)
.setBody(message)
.setData(data)
.setIdentity(identity)
.setSms(smsNumbers)
.create(restClient);
如果有帮助,请告诉我。