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


Java PhoneNumber类代码示例

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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