当前位置: 代码迷 >> 综合 >> NEXMO 发送国际短信,遇到的问题
  详细解决方案

NEXMO 发送国际短信,遇到的问题

热度:61   发布时间:2023-10-12 15:14:25.0

ps:

1.国内手机号发十条短信,只能收到一条(国外手机号正常)

2.中文乱码,用unicode转码发送

3.发送号码需添加国家编码(如中国86)

代码如下

public static void main(String[] args) {try {String NEXMO_API_KEY = "f591****";String NEXMO_API_SECRET = "ME7pPfBJLv******";String TO_NUMBER = "86177********";NexmoClient client = new NexmoClient.Builder().apiKey(NEXMO_API_KEY).apiSecret(NEXMO_API_SECRET).build();TextMessage message = new TextMessage("Acme Inc", TO_NUMBER, "A jinfei code is 4867 ,\u8c22\u8c22\u4f7f\u7528", true);SmsSubmissionResponse responses = client.getSmsClient().submitMessage(message);for (SmsSubmissionResponseMessage responseMessage : responses.getMessages()) {System.out.println(responseMessage);}} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();} catch (NexmoClientException e) {// TODO Auto-generated catch blocke.printStackTrace();}}