当前位置: 首页>>代码示例>>Java>>正文


Java Message类代码示例

本文整理汇总了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;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:14,代码来源:TwillioSmsSender.java

示例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();
}
 
开发者ID:kamax-io,项目名称:mxisd,代码行数:11,代码来源:PhoneSmsTwilioConnector.java

示例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();
}
 
开发者ID:mumukiller,项目名称:stock-patterns-recognition,代码行数:10,代码来源:SmsNotifierImpl.java

示例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());
    }
}
 
开发者ID:openMF,项目名称:message-gateway,代码行数:30,代码来源:TwilioMessageProvider.java

示例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();
}
 
开发者ID:vangav,项目名称:vos_backend,代码行数:20,代码来源:TwilioSender.java

示例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();
}
 
开发者ID:vangav,项目名称:vos_backend,代码行数:19,代码来源:TwilioSender.java

示例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());
}
 
开发者ID:TwilioDevEd,项目名称:api-snippets,代码行数:12,代码来源:SmsSender.7.x.java

示例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();
}
 
开发者ID:TwilioDevEd,项目名称:api-snippets,代码行数:12,代码来源:MmsSender.7.x.java

示例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());
}
 
开发者ID:TwilioDevEd,项目名称:api-snippets,代码行数:12,代码来源:example-1.7.x.java

示例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();
}
 
开发者ID:TwilioDevEd,项目名称:api-snippets,代码行数:8,代码来源:example-1.7.x.java

示例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());
}
 
开发者ID:TwilioDevEd,项目名称:api-snippets,代码行数:9,代码来源:instance-get-example-1.7.x.java

示例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());
  }
}
 
开发者ID:TwilioDevEd,项目名称:api-snippets,代码行数:11,代码来源:list-get-example-1.7.x.java

示例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());
    }
}
 
开发者ID:TwilioDevEd,项目名称:api-snippets,代码行数:15,代码来源:list-get-example-2.7.x.java

示例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
}
 
开发者ID:TwilioDevEd,项目名称:api-snippets,代码行数:12,代码来源:instance-post-example-1.7.x.java

示例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());
}
 
开发者ID:TwilioDevEd,项目名称:api-snippets,代码行数:13,代码来源:send-sms-callback.7.x.java


注:本文中的com.twilio.rest.api.v2010.account.Message类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。