本文整理汇总了Java中com.twilio.rest.api.v2010.account.Message类的典型用法代码示例。如果您正苦于以下问题:Java Message类的具体用法?Java Message怎么用?Java Message使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Message类属于com.twilio.rest.api.v2010.account包,在下文中一共展示了Message类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: send
import com.twilio.rest.api.v2010.account.Message; //导入依赖的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.rest.api.v2010.account.Message; //导入依赖的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: sendViaUnderlyingTransport
import com.twilio.rest.api.v2010.account.Message; //导入依赖的package包/类
/**
* Wrapper method for Twilio API
*/
protected void sendViaUnderlyingTransport(final String message){
log.debug("Message to send {}", message);
Message.creator(phoneReceiver, phoneSender, message)
.create();
}
示例4: sendMessage
import com.twilio.rest.api.v2010.account.Message; //导入依赖的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.rest.api.v2010.account.Message; //导入依赖的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.rest.api.v2010.account.Message; //导入依赖的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.rest.api.v2010.account.Message; //导入依赖的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.rest.api.v2010.account.Message; //导入依赖的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.rest.api.v2010.account.Message; //导入依赖的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());
}
示例10: main
import com.twilio.rest.api.v2010.account.Message; //导入依赖的package包/类
public static void main(String[] args) {
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
// Get an object from its sid. If you do not have a sid,
// check out the list resource examples on this page
Message.deleter("MM5ef8732a3c49700934481addd5ce1659").delete();
}
示例11: main
import com.twilio.rest.api.v2010.account.Message; //导入依赖的package包/类
public static void main(String[] args) {
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
// Get an object from its sid. If you do not have a sid,
// check out the list resource examples on this page
Message message = Message.fetcher("MM5ef8732a3c49700934481addd5ce1659").fetch();
System.out.println(message.getBody());
}
示例12: main
import com.twilio.rest.api.v2010.account.Message; //导入依赖的package包/类
public static void main(String[] args) {
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
ResourceSet<Message> messages = Message.reader().read();
// Loop over messages and print out a property for each one.
for (Message message : messages) {
System.out.println(message.getBody());
}
}
示例13: main
import com.twilio.rest.api.v2010.account.Message; //导入依赖的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());
}
}
示例14: main
import com.twilio.rest.api.v2010.account.Message; //导入依赖的package包/类
public static void main(String[] args) {
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
// Get an object from its sid. If you do not have a sid,
// check out the list resource examples on this page
String messageSid = "MM5ef8732a3c49700934481addd5ce1659";
String body = "";
Message message = Message.updater(messageSid, body).update();
System.out.println(message.getBody()); // will be empty string
}
示例15: main
import com.twilio.rest.api.v2010.account.Message; //导入依赖的package包/类
public static void main(String[] args) {
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
Message message = Message.creator(
new PhoneNumber("+15558675310"),
new PhoneNumber("+15017122661"),
"McAvoy or Stewart? These timelines can get so confusing.")
.setStatusCallback("http://requestb.in/1234abcd")
.create();
System.out.println(message.getSid());
}