如何使用 sid 获取 Twilio 通知的状态? [英] How to get the status of a Twilio Notification using the sid?

查看:20
本文介绍了如何使用 sid 获取 Twilio 通知的状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用通知 API(Twilio Java SDK 版本 7.24.2).我已经使用通知 API 成功发送了短信,例如:<代码>private String sendMessageThroughNotificationService(String message, PhoneNumber receiverPhoneNumber){通知通知 = Notification.creator(twilioNotificationSID).setBody(消息).setToBinding(Promoter.listOfOne("{\"binding_type\":\"sms\", \"address\":\""+receiverPhoneNumber.toString()+"\"}")).创建();返回notification.getSid();}

I am using the Notifications APIs (Twilio Java SDK version 7.24.2). I've successfully sent the SMSes using the Notification API like: private String sendMessageThroughNotificationService(String message, PhoneNumber receiverPhoneNumber){ Notification notification = Notification.creator(twilioNotificationSID) .setBody(message) .setToBinding(Promoter.listOfOne("{\"binding_type\":\"sms\", \"address\":\""+receiverPhoneNumber.toString()+"\"}")) .create(); return notification.getSid(); }

现在,如果我想通过我从上述方法返回的通知的 SID 获取通知的状态,我该怎么办?Twilio 的 Java 通知 API 是否提供了通过其 SID 查找通知状态的任何方法(如果我不想使用注册回调 URL 方法)?

Now, what should I do if I want to get the Notification's status through the SID of the notification that I am returning from the above method? Does Twilio's Java Notification's API provide any way to find the Notification's status through its SID (if I don't want to use the register callback URL approach)?

推荐答案

Twilio 开发人员布道者在这里.

Twilio developer evangelist here.

如果您一次只通过 SMS 发送一个通知,那么我建议您只使用 消息 API.这样 API 将返回消息 SID,然后您可以将其用于 使用 API 查找消息并检查其状态.

If you are only sending one notification at a time via SMS, then I recommend you just use the Messages API. That way the API will return the Message SID, which you can then use to look up the Message with the API and check its status.

无法查找通过 Notify 发送的所有消息以检查其状态.推荐的方法是注册一个 StatusCallbackUrl 以获取每个状态的更新.

There is no way to look up all the messages sent via Notify in order to check their statuses. The recommended method there is to register a StatusCallbackUrl to get updates on each status.

让我知道这是否有帮助.

Let me know if that helps at all.

这篇关于如何使用 sid 获取 Twilio 通知的状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆