Skip to content

9. Node

Yohannes Mekonnen edited this page Sep 5, 2023 · 1 revision

Nodejs

# Sending SMS to a Single Phone with Nodejs

const axios = require('axios');
let data = JSON.stringify({
    "username": "your_username",
    "password": "your_password",
    "to": "9xxxxxxxxx",
    "text": "your_message"
});

let config = {
    method: 'post',
    maxBodyLength: Infinity,
    url: 'your_single_url',
    headers: {
        'Content-Type': 'application/json'
    },
    data : data
};

axios.request(config)
    .then((response) => {
        console.log(JSON.stringify(response.data));
    })
    .catch((error) => {
        console.log(error);
    });

# Sending SMS to a Multiple Phone with Nodejs

const axios = require('axios');
let data = JSON.stringify({
    "username": "your_username",
    "password": "your_password",
    "to": [
        "9xxxxxxxxx",
        "9xxxxxxxxx",
        "9xxxxxxxxx"
    ],
    "text": "your_message"
});

let config = {
    method: 'post',
    maxBodyLength: Infinity,
    url: 'your_list_url',
    headers: {
        'Content-Type': 'application/json'
    },
    data : data
};

axios.request(config)
    .then((response) => {
        console.log(JSON.stringify(response.data));
    })
    .catch((error) => {
        console.log(error);
    });
Clone this wiki locally