使用 java 的 AWS 短信

Aws SMS using java

我已经编写了一个代码,使用 java 将短信发送到特定的 phone 号码,它使用 AWS-SNS API,它工作正常,但我只是想验证是否消息是否已送达。 例如:说手机号码是否错误或不存在 +910000000000

下面是我的代码

import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.sns.AmazonSNS;
import com.amazonaws.services.sns.AmazonSNSClient;
import com.amazonaws.services.sns.model.PublishRequest;

public class SMSClass {

    public static void main(String[] args) {
        
        //Used for authenticating to AWS
        BasicAWSCredentials awsCreds = new BasicAWSCredentials("Access_Key", "Secret_Access_Key");
        
        //Create SNS Client
        AmazonSNS snsClient = AmazonSNSClient
                .builder()
                .withRegion(Regions.AP_SOUTHEAST_2)
                .withCredentials(new AWSStaticCredentialsProvider(awsCreds))
                .build();
        
        String SMSMessage = "Sent using AWS SNS";
        String mobile = "+910000000000";//Enter your mobile number here
        
        snsClient.publish(new PublishRequest().withMessage(SMSMessage).withPhoneNumber(mobile));
        
        

    }

}

任何帮助都会非常有用提前致谢

您可以使用 AWS document 中提到的 Cloudwatch Logs 服务。