Monday, 8 May 2017

Confused sending sms using aws

I'm writing a program that sends SMS using the AWS SNS service. I am new to this topic. So I've tried one of the codes available online.

and the code is as below.

var AWS = require('aws-sdk');

AWS.config.region = 'your aws region';
AWS.config.update({
    accessKeyId: "your access id",
    secretAccessKey: "your secret access key",
});

var sns = new AWS.SNS();
var params = {
    Message: "your message",
    MessageStructure: 'string',
    PhoneNumber: 'phone_number_without_+',
    Subject: 'your subject'
};

sns.publish(params, function (err, data) {
    if (err) console.log(err, err.stack); // an error occurred
    else console.log(data);           // successful response
});

Here I've filled the entire data from my AWS console like Region, accessKey and secretAccessKey, my mobile number, Subject and message. post filling this when I try to run this, I get the below response.

{ ResponseMetadata: { RequestId: '30d54840-1aa8-5ad4-8de7-19cad1ed033f' },
  MessageId: '7cc1d99e-b835-5015-b84e-88147370a9fe' }

but there is no sms delivered to my mobile.

I thought that the service is not available in my country and then tried sending the message from SMS console shown below. I received a text message on my mobile.

enter image description here

Here I'm not using any topic and I need to send message individually, there is no bulk message to be sent.

Please guide me on where am I going wrong and how can I fix this.

Thanks



via user3872094

No comments:

Post a Comment