本文整理汇总了Java中com.twilio.type.PhoneNumber类的典型用法代码示例。如果您正苦于以下问题:Java PhoneNumber类的具体用法?Java PhoneNumber怎么用?Java PhoneNumber使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PhoneNumber类属于com.twilio.type包,在下文中一共展示了PhoneNumber类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: send
import com.twilio.type.PhoneNumber; //导入依赖的package包/类
@Override
public boolean send(final String from, final String to, final String message) {
try {
Message.creator(
new PhoneNumber(to),
new PhoneNumber(from),
message).create();
return true;
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return false;
}
示例2: send
import com.twilio.type.PhoneNumber; //导入依赖的package包/类
@Override
public void send(String recipient, String content) {
if (StringUtils.isBlank(cfg.getAccountSid()) || StringUtils.isBlank(cfg.getAuthToken()) || StringUtils.isBlank(cfg.getNumber())) {
throw new BadRequestException("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());
Message.creator(new PhoneNumber("+" + recipient), new PhoneNumber(cfg.getNumber()), content).create();
}
示例3: SmsNotifierImpl
import com.twilio.type.PhoneNumber; //导入依赖的package包/类
@Autowired
public SmsNotifierImpl(final @Value("${twilio.account-sid}") String accountSid,
final @Value("${twilio.auth-token}") String authToken,
final @Value("${twilio.phone-from}") String phoneSender,
final @Value("${twilio.phone-to}") String phoneReceiver) {
initializeUnderlyingTransport(accountSid, authToken);
this.phoneSender = new PhoneNumber(phoneSender);
this.phoneReceiver = new PhoneNumber(phoneReceiver);
}
示例4: sendMessage
import com.twilio.type.PhoneNumber; //导入依赖的package包/类
@Override
public void sendMessage(final SMSBridge smsBridgeConfig, final SMSMessage message)
throws MessageGatewayException {
//Based on message id, register call back. so that we get notification from Twilio about message status
String statusCallback = callBackUrl+message.getId() ;
final TwilioRestClient twilioRestClient = this.getRestClient(smsBridgeConfig);
builder.setLength(0);
builder.append(smsBridgeConfig.getCountryCode()) ;
builder.append(message.getMobileNumber()) ;
String mobile = builder.toString() ;
logger.info("Sending SMS to " + mobile + " ...");
MessageCreator creator = new MessageCreator(new PhoneNumber(mobile), new PhoneNumber(smsBridgeConfig.getPhoneNo()) , message.getMessage() ) ;
creator.setStatusCallback(statusCallback) ;
try {
message.setSubmittedOnDate(new Date());
Message twilioMessage = creator.create(twilioRestClient) ;
message.setExternalId(twilioMessage.getSid());
logger.debug("TwilioMessageProvider.sendMessage():"+TwilioStatus.smsStatus(twilioMessage.getStatus()).getValue());
message.setDeliveryStatus(TwilioStatus.smsStatus(twilioMessage.getStatus()).getValue()) ;
if(message.getDeliveryStatus().equals(SmsMessageStatusType.FAILED.getValue())) {
message.setDeliveryErrorMessage(twilioMessage.getErrorMessage());
logger.error("Sending SMS to :"+message.getMobileNumber()+" failed with reason "+twilioMessage.getErrorMessage());
}
}catch (ApiException e) {
logger.error("ApiException while sending message to :"+message.getMobileNumber()+" with reason "+e.getMessage());
message.setDeliveryStatus(SmsMessageStatusType.FAILED.getValue());
message.setDeliveryErrorMessage(e.getMessage());
}
}
示例5: sendSync
import com.twilio.type.PhoneNumber; //导入依赖的package包/类
/**
* sendSync
* blocking method
* @param twilioSms
* @return sent sms's sid
* @throws Exception
*/
public String sendSync (TwilioSms twilioSms) throws Exception {
Message message =
Message
.creator(
new PhoneNumber(twilioSms.getToPhoneNumber() ),
new PhoneNumber(twilioSms.getFromPhoneNumber() ),
twilioSms.getMessage() )
.create();
return message.getSid();
}
示例6: sendAsync
import com.twilio.type.PhoneNumber; //导入依赖的package包/类
/**
* sendAsync
* non-blocking method
* @param twilioSms
* @return ListenableFuture<Message> of the sms being sent asynchronously
* @throws Exception
*/
public ListenableFuture<Message> sendAsync (
TwilioSms twilioSms) throws Exception {
return
Message
.creator(
new PhoneNumber(twilioSms.getToPhoneNumber() ),
new PhoneNumber(twilioSms.getFromPhoneNumber() ),
twilioSms.getMessage() )
.createAsync();
}
示例7: main
import com.twilio.type.PhoneNumber; //导入依赖的package包/类
public static void main(String[] args) {
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
Message message = Message
.creator(new PhoneNumber("+14159352345"), // to
new PhoneNumber("+14158141829"), // from
"Where's Wallace?")
.create();
System.out.println(message.getSid());
}
示例8: main
import com.twilio.type.PhoneNumber; //导入依赖的package包/类
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(new PhoneNumber("+14159352345"), // to
new PhoneNumber("+14158141829"), // from
"Where's Wallace?")
.setMediaUrl(new URI(uri))
.create();
}
示例9: main
import com.twilio.type.PhoneNumber; //导入依赖的package包/类
public static void main(String[] args) {
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
// Get Twilio Voice pricing for calls to/from a specific number
Number voiceNumber = Number.fetcher(new PhoneNumber("+15108675310")).fetch();
System.out.println(voiceNumber.getOutboundCallPrice().getCurrentPrice());
}
示例10: main
import com.twilio.type.PhoneNumber; //导入依赖的package包/类
public static void main(String[] args) {
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
ResourceSet<IncomingPhoneNumber> numbers =
IncomingPhoneNumber.reader().setPhoneNumber(new PhoneNumber("867")).read();
// Loop over numbers and print out a property for each one.
for (IncomingPhoneNumber number : numbers) {
System.out.println(number.getVoiceUrl());
}
}
示例11: main
import com.twilio.type.PhoneNumber; //导入依赖的package包/类
public static void main(String[] args) {
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
IncomingPhoneNumber number = IncomingPhoneNumber.creator(new PhoneNumber("+15105647903"))
.setFriendlyName("My Company Line").setVoiceUrl("http://demo.twilio.com/docs/voice.xml")
.setVoiceMethod(HttpMethod.GET).create();
System.out.println(number.getSid());
}
示例12: main
import com.twilio.type.PhoneNumber; //导入依赖的package包/类
public static void main(String[] args) {
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
ResourceSet<IncomingPhoneNumber> numbers =
IncomingPhoneNumber.reader().setPhoneNumber(new PhoneNumber("+14158675310")).read();
// Loop over numbers and print out a property for each one.
for (IncomingPhoneNumber number : numbers) {
System.out.println(number.getPhoneNumber());
}
}
示例13: main
import com.twilio.type.PhoneNumber; //导入依赖的package包/类
public static void main(String[] args) {
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
Message message = Message
.creator(new PhoneNumber("+15558675310"), new PhoneNumber("+14158141829"),
"Let's grab lunch at Milliways tomorrow!")
.setMediaUrl("http://www.example.com/cheeseburger.png")
.create();
System.out.println(message.getSid());
}
示例14: main
import com.twilio.type.PhoneNumber; //导入依赖的package包/类
public static void main(String[] args) {
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
ResourceSet<Message> messages = Message
.reader()
.setTo(new PhoneNumber("to_number"))
.setFrom(new PhoneNumber("from_number"))
.setDateSent(DateTime.parse("2016-01-01'T'09:28:00Z")).read();
// Loop over messages and print out a property for each one.
for (Message message : messages) {
System.out.println(message.getBody());
}
}
示例15: main
import com.twilio.type.PhoneNumber; //导入依赖的package包/类
public static void main(String[] args) throws URISyntaxException {
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
Call call = Call
.creator(new PhoneNumber("+14155551212"), new PhoneNumber("+18668675310"),
new URI("http://demo.twilio.com/docs/voice.xml"))
.setMethod(HttpMethod.GET).setSendDigits("1234#").create();
System.out.println(call.getSid());
}