Lenguaje "Javascript"

Enviar mensajes – REST API – JSON

var data = JSON.stringify({
  "message": "Text of the SMS message",
  "tpoa": "Sender",
  "recipient": [
    {
      "msisdn": "12015550123"
    },
    {
      "msisdn": "447400123456"
    },
    {
      "msisdn": "5212221234567"
    }
  ]
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://api.labsmobile.com/json/send");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Basic " + btoa("myusername:mypassword"));
xhr.setRequestHeader("Cache-Control", "no-cache");

xhr.send(data);

Consulta de créditos – REST API – JSON

var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://api.labsmobile.com/json/balance");
xhr.setRequestHeader("Authorization", "Basic " + btoa("myusername:mypassword"));
xhr.setRequestHeader("Cache-Control", "no-cache");

xhr.send(data);

Enviar mensajes – HTTP/GET

function httpGet(theUrl)
{
    var xmlHttp = new XMLHttpRequest();
    xmlHttp.open( "GET", theUrl, false );
    xmlHttp.send( null );
    return xmlHttp.responseText;
}
httpGet("http://api.labsmobile.com/get/send.php?username=[X]&password=[X]&msisdn=34609036253&sender=SENDER&message=This+is+the+message");

Consulta de créditos – HTTP/GET

function httpGet(theUrl)
{
    var xmlHttp = new XMLHttpRequest();
    xmlHttp.open( "GET", theUrl, false );
    xmlHttp.send( null );
    return xmlHttp.responseText;
}
httpGet("http://api.labsmobile.com/get/balance.php?username=[X]&password=[X]");

Llámanos