Example code for SMS integration in language Node.js

Send SMS - REST API - JSON

            
var http = require("https");
var btoa = require("btoa");
var options = {
  "method": "POST",
  "hostname": [
    "api",
    "labsmobile",
    "com"
  ],
  "path": [
    "json",
    "send"
  ],
  "headers": {
    "Content-Type": "application/json",
    "Authorization": "Basic " + btoa("myusername:mypassword"),
    "Cache-Control": "no-cache"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({ message: 'Text of the SMS message',
  tpoa: 'Sender',
  recipient:
   [ { msisdn: '12015550123' },
     { msisdn: '447400123456' },
     { msisdn: '5212221234567' } ] }));
req.end();

Credit inquiry - REST API - JSON

            
var http = require("https");
var btoa = require("btoa");
var options = {
  "method": "GET",
  "hostname": [
    "api",
    "labsmobile",
    "com"
  ],
  "path": [
    "json",
    "balance"
  ],
  "headers": {
    "Authorization": "Basic " + btoa("myusername:mypassword"),
    "Cache-Control": "no-cache",
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();

Send SMS - HTTP/GET


var request = require('request');

request({
    url: 'http://api.labsmobile.com/get/send.php?username=[X]&password=[X]&msisdn=34609036253&sender=SENDER&message=This+is+the+message',
    method: 'GET',
}, function(error, response, body){
    if(error) {
        console.log(error);
    } else {
        console.log(response.statusCode, body);
    }
});

Credit inquiry - HTTP/GET


var request = require('request');

request({
    url: 'http://api.labsmobile.com/get/balance.php?username=[X]&password=[X]',
    method: 'GET',
}, function(error, response, body){
    if(error) {
        console.log(error);
    } else {
        console.log(response.statusCode, body);
    }
});
  • contact form support

    Sign up!

    Create a user account and send your SMS messages in seconds. You will have all the functionalities and benefits in the same platform.

    Send from API and manage your account with our online application WebSMS.

    Create new account
  • IT consultant, Computer security and processes recommends LabsMobile

    Sending access codes, authentication, user identification and validation processes with SMS messages.

    Watch more reviews
  • dashboard aplicación online

    Maximum reliability at the best price

    At LabsMobile we only offer direct routes of maximum reliability and quality. Enjoy our platform and all our services for the price of an SMS.

    Pay ONLY for sent messages.

    Check our rates
  • dashboard aplicación online

    Need more info? Contact us!

    Our technical department has professionals with years of experience and we have made multiple integrations.

    We guide and help you through the process.

    Request technical support
  • Send a survey or form by SMS

    This tutorial explains how to send a survey or user evaluation (review) through SMS messages.

    Ir al tutorial
loader