use of com.twilio.type.PhoneNumber in project api-snippets by TwilioDevEd.
the class MmsSender method main.
public static void main(String[] args) throws URISyntaxException {
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
String uri = "https://static0.twilio.com/recources/logos/twilio-loco-circle-50x50.png";
Message message = Message.creator(// to
new PhoneNumber("+14159352345"), // from
new PhoneNumber("+14158141829"), "Where's Wallace?").setMediaUrl(new URI(uri)).create();
}
use of com.twilio.type.PhoneNumber in project api-snippets by TwilioDevEd.
the class SmsSender method main.
public static void main(String[] args) {
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
Message message = Message.creator(// to
new PhoneNumber("+14159352345"), // from
new PhoneNumber("+14158141829"), "Where's Wallace?").create();
System.out.println(message.getSid());
}
use of com.twilio.type.PhoneNumber in project mxisd by kamax-io.
the class PhoneSmsTwilioConnector method send.
@Override
public void send(String recipient, String content) {
if (StringUtils.isBlank(cfg.getAccountSid()) || StringUtils.isBlank(cfg.getAuthToken()) || StringUtils.isBlank(cfg.getNumber())) {
log.error("Twilio connector in not fully configured and is missing mandatory configuration values.");
throw new NotImplementedException("Phone numbers cannot be validated at this time. Contact your administrator.");
}
recipient = "+" + recipient;
log.info("Sending SMS notification from {} to {} with {} characters", cfg.getNumber(), recipient, content.length());
try {
Message.creator(new PhoneNumber("+" + recipient), new PhoneNumber(cfg.getNumber()), content).create();
} catch (ApiException e) {
throw new InternalServerError(e);
}
}
use of com.twilio.type.PhoneNumber in project api-snippets by TwilioDevEd.
the class MakePhoneCall method main.
public static void main(String[] args) throws URISyntaxException {
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
String from = "+15017122661";
String to = "+14155551212";
Call call = Call.creator(new PhoneNumber(to), new PhoneNumber(from), new URI("http://demo.twilio.com/docs/voice.xml")).create();
System.out.println(call.getSid());
}
use of com.twilio.type.PhoneNumber in project thingsboard by thingsboard.
the class TwilioSmsSender method sendSms.
@Override
public int sendSms(String numberTo, String message) throws SmsException {
numberTo = this.validatePhoneNumber(numberTo);
message = this.prepareMessage(message);
try {
String numSegments = Message.creator(new PhoneNumber(numberTo), new PhoneNumber(this.numberFrom), message).create(this.twilioRestClient).getNumSegments();
return Integer.valueOf(numSegments);
} catch (Exception e) {
throw new SmsSendException("Failed to send SMS message - " + e.getMessage(), e);
}
}
Aggregations