Currently i am using Springboot with kotlin to send SMS using AWS SNS to person in Vietnam.
however it keeps sending a message with last string in my message contents.
@Bean
fun snsClient(): AmazonSNS {
val credentials = BasicAWSCredentials(accessKey, secretKey)
val snsClient = AmazonSNSClient.builder()
.withRegion(Regions.AP_SOUTHEAST_1)
.withCredentials(AWSStaticCredentialsProvider(credentials))
.build()
return snsClient
}
private fun sendMsg(snsClient: AmazonSNS, msg: String, phoneNumber: String) {
try {
val req = PublishRequest()
req.message = msg
req.phoneNumber = phoneNumber
val res = snsClient.publish(req)
System.out.println(res.sdkResponseMetadata)
} catch (e: AmazonSNSException) {
e.printStackTrace()
}
}
can anyone help me with this problem?
according to aws documentation, it tells me to use PublishRequest().builder() . but, when i try to use builder() method, there is no builder() method in PublishRequest().