繁体   English   中英

Twilio短信使用Java发送给定错误

[英]Twilio sms sending giving errors , using java

我尝试将短信从我的电话号码发送到我的电话号码。 它给了我错误提示:“线程“ main” com.twilio.exception.ApiException中的异常:找不到所请求的资源/2010-04-01/Accounts/myaccountusername@gmail.com/Messages.json

public static void main(String[] args) {
        Twilio.init("myaccountusername@gmail.com", "mypassword");
        Message message = Message.creator(new PhoneNumber("+947XXXXXXXX"),
    new PhoneNumber("+947XXXXXXXX"), "This is the ship that made the Kessel Run in fourteen parsecs?").create();

System.out.println(message.getSid());
}

我是这个新手。 我需要专家告诉我此异常的原因是什么以及如何解决它

它是Twilio.init(ACCOUNT_SID, AUTH_TOKEN); 不是Twilio.init("myaccountusername@gmail.com", "mypassword");

您不能使用您的电子邮件地址和密码。 登录https://www.twilio.com/console上的 Twilio控制台后,您可以在仪表板上找到正确的ACCOUNT_SIDAUTH_TOKEN值。

在此处输入图片说明

Twilio文档https://www.twilio.com/docs/libraries/java#testing-your-installation

// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Message;
import com.twilio.type.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    Message message = Message.creator(new PhoneNumber("+15558675309"),
        new PhoneNumber("+15017250604"), 
        "This is the ship that made the Kessel Run in fourteen parsecs?").create();

    System.out.println(message.getSid());
  }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM