我如何知道 SMS 是否已到达 Twilio 的目的地 [英] how do I know if SMS has reached at destination in Twilio

查看:31
本文介绍了我如何知道 SMS 是否已到达 Twilio 的目的地的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个网络应用程序,我正在使用 twilio 网关发送 SMS.我需要在我的页面上显示 SMS 的状态.如果 SMS 已发送,那么它将显示已发送,否则它将显示待处理.所以请告诉我如何知道消息是否已送达.

i am developing a web app and in that I am sending SMS using twilio gateway.I need to show on my page the status of SMS.If SMS is sent then it will show delivered else it will show pending. So please tell me how do i know whether the message has been delivered or not.

以下是示例代码

public class Example {

  public static final String ACCOUNT_SID = "AC5b8866a232v3b63bfgh0f9a872b2dfddd";
  public static final String AUTH_TOKEN = "7a0068ca7d07036cbbddeba03370aujdhnm";

  public static void main(String[] args) throws TwilioRestException {
    TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

    Map<String, String> params = new HashMap<String, String>();

    params.put("To", "+number");
    params.put("From", "+number");
 System.out.println(System.getProperty("java.class.path"));
    SmsFactory messageFactory = client.getAccount().getSmsFactory();
    Sms message = messageFactory.create(params);

  }
}

推荐答案

Twilio 布道者在这里.

Twilio evangelist here.

首先请注意,SmsMessages 资源已被弃用,您现在应该使用新的 Messages 端点.您可以查看发送短信快速入门以了解更新显示如何通过 Java 帮助程序库使用新资源的 Java 代码.

First of all please note that the SmsMessages resource has been deprecated and you should now be using the new Messages endpoint. You can check out the Sending SMS Messages quickstart for updated Java code that shows how to use the new resource with the Java helper library.

第二,为了在消息状态更改时接收通知,您应该包含 StatusCallback 参数,当您发送消息时.包含此参数会告诉 Twilio 在消息状态更改时向参数 URL 发出请求.

Second, in order to receive notifications as a Messages status changes you should include the StatusCallback parameter when you send the Message. Including this parameter tells Twilio to make a request to the parameters URL when the message status changes.

另请注意,由于您的帖子标题不清楚,已发送"状态简单表示 Twilio 已成功将消息发送给运营商.这并不一定意味着承运人能够将消息传递给预期的收件人.

Also note since its not clear from your post title, the "sent" status simple means that Twilio successfully sent the message to the carrier. It does not necessarily mean that the carrier was able to deliver the message to the intended recipient.

希望有所帮助.

这篇关于我如何知道 SMS 是否已到达 Twilio 的目的地的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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