fork from https://github.com/billbarsch/myzap cara penggunaan
- git clone https://github.com/diazzaid/myzap.git
- cd myzap
- npm install`
Start server
- node index.js`
keep processes alive at every server restart
npm install -y pm2 -g
pm2 start index.js
pm2 startup
Usage
Start new whatsapp session / multi session
http://localhost:3333/start?sessionName=session1
Get QRCode
http://localhost:3333/qrcode?sessionName=session1
- json (base64)
Send message (POST method)
(async () => {
const response = await fetch('http://localhost:3333/send-message', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(
{
sender: "session1",
number: '556334140378',
message:"Hello\nWorld"
}
)
});
const content = await response.json();
console.log(content);
})();
Send File (POST method)
(async () => {
const response = await fetch('http://localhost:3333/send-media', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(
{
sender: "session1",
number: '556334140378',
base64Data:"44696d61", //hexadecimal
fileName:"test.txt",
caption: "Document" //optional
}
)
});
const content = await response.json();
console.log(content);
})();