我正在尝试向我已验证的电话号码发送消息,我在
上看到我从
获得的号码发送我的代码看起来像
object TextMessage {
def send() = {
// Create a rest client
val client: TwilioRestClient = new TwilioRestClient("AC*****", "324324234******")
val mainAccount: Account = client.getAccount
val messageFactory: SmsFactory = mainAccount.getSmsFactory
var messageParams: List[NameValuePair] = List[NameValuePair]()
messageParams = messageParams :+ new BasicNameValuePair("To", "MyVerifiedNumber")
messageParams = messageParams :+ new BasicNameValuePair("From", "NumberIGotFromTwilio")
messageParams = messageParams :+ new BasicNameValuePair("Body", "The system crashed just now!")
println(messageParams)
messageFactory.create(ListBuffer(messageParams).flatten)
}
def main(args: Array[String]) {
TextMessage.send()
}
}
当我跑步时,我得到以下
Exception in thread "main" com.twilio.sdk.TwilioRestException: The From phone number +1NumberIGotFromTwilio is not a valid, SMS-capable inbound phone number or short code for your account.
at com.twilio.sdk.TwilioRestException.parseResponse(TwilioRestException.java:74)
at com.twilio.sdk.TwilioClient.safeRequest(TwilioClient.java:509)
at com.twilio.sdk.resource.list.SmsList.create(SmsList.java:79)
at com.shn.enterpriseconnector.util.TextMessage$.send(TextMessage.scala:25)
at com.shn.enterpriseconnector.util.TextMessage$.main(TextMessage.scala:29)
at com.shn.enterpriseconnector.util.TextMessage.main(TextMessage.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)