0
我正在使用AWS通过我的应用程序发送SMS。SMS无法通过SDK发送任何异常(它与AWS Web Console一起使用)
我可以通过AWS Web控制台发送短信,但通过SDK发送短信不成功,没有任何异常信息,发送请求状态为200,仍然收到返回值AWS_REQUEST_ID。
AmazonSNSClient snsClient = new AmazonSNSClient(new BasicAWSCredentials(accessKey, secretKey));
Map<String, MessageAttributeValue> smsAttributes = new HashMap<String, MessageAttributeValue>();
smsAttributes.put("AWS.SNS.SMS.SenderID", new MessageAttributeValue()
.withStringValue("mySenderID") //The sender ID shown on the device.
.withDataType("String"));
smsAttributes.put("AWS.SNS.SMS.MaxPrice", new MessageAttributeValue()
.withStringValue("1") //Sets the max price to 0.50 USD.
.withDataType("Number"));
// Sets the type to promotional
smsAttributes.put("AWS.SNS.SMS.SMSType",
new MessageAttributeValue().withStringValue("Promotional").withDataType("String"));
JSONObject smsService = (JSONObject) new JSONObject(json).get("smsService");
String phoneNumber = smsService.getString("phoneNumber");
String message = smsService.getString("message");
PublishResult result = snsClient.publish(new PublishRequest().withMessage(message).withPhoneNumber(phoneNumber) .withMessageAttributes(smsAttributes)); LOGGER.info("Message ID: {}", result); // Prints the message ID.