有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

使用Java的Twilio Rest Api的安卓交付报告

我正在尝试报告接收者是否收到短信? 我可以发送短信,但Twilio不会回拨我指定的URL 以下是我的代码片段:-

// Create a rest client
  TwilioRestClient client = new TwilioRestClient(com.main.Constants.ACCOUNT_SID,                    com.main.Constants.AUTH_TOKEN);

 // Get the main account (The one we used to authenticate the client
   Account mainAccount = client.getAccount();

 // Get all accounts including sub accounts
  AccountList accountList = client.getAccounts();

  // Send an sms
  SmsFactory smsFactory = mainAccount.getSmsFactory();
  Map<String, String> smsParams = new HashMap<String, String>();
  smsParams.put("To", number); // Replace with a valid phone

  // number in your account
  smsParams.put("From", com.main.Constants.FROM); // Replace with a valid                                   

  smsParams.put("StatusCallback", com.main.Constants.CALLBACKURL);

  smsParams.put("Body", "Token : " + token);

  sms = smsFactory.create(smsParams);

共 (1) 个答案

  1. # 1 楼答案

    Twilio应该向callback URL发送一个短信状态的请求

    通过将回调URL设置为可以检查传入HTTP请求(例如http://uncurler.heroku.com/)的站点,并发送测试SMS,可以验证回调URL实际上没有被命中吗?然后刷新Uncurler上的示例页面,查找入站HTTP请求

    另一种可能性是,你的出站短信被拒绝,因此Twilio永远不会将邮件排队等待发送。检查smsFactory提出的异常。create()行,并检查那里的错误消息