whatsappService.js
unknown
javascript
2 years ago
1.1 kB
4
Indexable
const fs = require("fs"); const myConsole = new console.Console(fs.createWriteStream("./logs.txt")); const https = require("https"); function SendMessageWhatsApp(textResponse, number){ const data = JSON.stringify({ "messaging_product": "whatsapp", "recipient_type": "individual", "to": number, "type": "text", "text": { "preview_url": false, "body": textResponse } }); const options = { host: "graph.facebook.com", path:"/v15.0/111974405102******/messages", method: "POST", body: data, headers: { "Content-Type": "application/json", Authorization: "Bearer EAAWNbICfuWEBAK5ObPbDborZC7VVj******..." } }; const req = https.request(options, res => { res.on("data", d=> { process.stdout.write(d); }); }); req.on("error", error => { console.error(error); }) req.write(data); req.end(); } module.exports = { SendMessageWhatsApp };
Editor is loading...