Vonage / vonage-node-sdk

Vonage API client for Node.js. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.
Apache License 2.0
380 stars 181 forks source link

SMS not being sent #32

Closed diegoaguilar closed 8 years ago

diegoaguilar commented 8 years ago

So, I have credits in my nexmo account, I'm trying to send an SMS and with debug mode on, I can see:

sending message from NEXMO to +521222205xxxx with message Nexmo - rollbar winston test
{ host: 'rest.nexmo.com',
  port: 80,
  path: '/sms/json?&api_key=a8xxxxxx&api_secret=85xxxxxx',
  method: 'POST',
  headers:
   { 'Content-Type': 'application/x-www-form-urlencoded',
     accept: 'application/json',
     'Content-Length': 0 } }
response ended

I've confirmed the api key and the api secret, but any SMS is being sent. Suggestions?

pvela commented 8 years ago

What "FROM" number are you using to send this message?

Some of the constraints to be aware of :

New accounts can only send to numbers that have been verified in the dashboard, and 'Nexmo Demo' will be added to all messages. Once you've added funds to your account, those restrictions will be removed.

diegoaguilar commented 8 years ago

Well I'm using a placeholder text as the "FROM" number, and eventhough I've not purchased any numbers, I've already bought credits.

I achieved sending SMS with this code:

function requestSMS(key, secret, text, from, to, options) {
  options = options || {};
  var post = {
    api_key: key,
    api_secret: secret,
    from: from,
    to: to,
    text: text.toString(),
  };
  if (options.debug) {
      winston.debug('About to send SMS from % to %', from, to);
      winston.debug(post);
  }

  request.post(
    'https://rest.nexmo.com/sms/json',
    { form: post },
    (err, httpResponse, body) => {
    if (err && options.debug) {
      winston.debug('Request to send SMS failed');
      winston.debug(err);
    } else if (options.debug) {
      winston.debug(body);
    }
  });
}
pvela commented 8 years ago

Are you saying that you were able to send a message using the direct API call and its not working with the NPM package easynexmo with the same set of parameters (key, secret, from and to)?

diegoaguilar commented 8 years ago

Yep, exactly that :( On Mar 2, 2016 12:29 AM, "prabhu" notifications@github.com wrote:

Are you saying that you were able to send a message using the direct API call and its not working with the NPM package easynexmo with the same set of parameters (key, secret, from and to)?

— Reply to this email directly or view it on GitHub https://github.com/pvela/nexmo/issues/32#issuecomment-191087950.

diegoaguilar commented 8 years ago

@pvela any opinions or suggestions?

pvela commented 8 years ago

@diegoaguilar Tried many times but couldn't replicate the problem. After taking a closer look at your output from the initial paste it looks like you are connecting to port 80, which is not the correct port to connect to. Can you verify if you are using the latest version of the library and check if you have overwritten the port from 443 to 80.