sddsdsdsds
This commit is contained in:
parent
08476f4b45
commit
fcbfef91a2
92
index.js
92
index.js
@ -457,42 +457,26 @@ app.post('/sendProductMessage', async (req, res) => {
|
|||||||
await sock.sendMessage(
|
await sock.sendMessage(
|
||||||
jid,
|
jid,
|
||||||
{
|
{
|
||||||
product: {
|
product: {
|
||||||
productImage: { url: "https://wa.canguidev.fr/static/logo-merlo-cs-FR.jpg"},
|
productImage: { url: productImageUrl },
|
||||||
productImageCount: 1,
|
productImageCount,
|
||||||
title: "Title Product",
|
title: productTitle,
|
||||||
description: "Description Product",
|
description: productDescription,
|
||||||
priceAmount1000: 20000 * 1000,
|
priceAmount1000,
|
||||||
currencyCode: "IDR",
|
currencyCode,
|
||||||
retailerId: "Retail",
|
retailerId,
|
||||||
url: "https://example.com",
|
url: productUrl,
|
||||||
},
|
},
|
||||||
businessOwnerJid: "33617452235@s.whatsapp.net",
|
businessOwnerJid,
|
||||||
caption: "Description Of Messages", //Additional information
|
caption,
|
||||||
title: "Title Of Messages",
|
title: messageTitle,
|
||||||
footer: "Footer Messages",
|
footer,
|
||||||
media: true,
|
media: true,
|
||||||
interactiveButtons: [
|
interactiveButtons
|
||||||
{
|
|
||||||
name: "quick_reply",
|
|
||||||
buttonParamsJson: JSON.stringify({
|
|
||||||
display_text: "Display Button",
|
|
||||||
id: "ID"
|
|
||||||
})
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "cta_url",
|
|
||||||
buttonParamsJson: JSON.stringify({
|
|
||||||
display_text: "Display Button",
|
|
||||||
url: "https://www.example.com"
|
|
||||||
})
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
quoted ? { quoted } : {}
|
||||||
quoted : message
|
);
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
return res.json({ success: true });
|
return res.json({ success: true });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -602,6 +586,44 @@ app.post('/testHeaderImage', async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const express = require('express');
|
||||||
|
const app = express();
|
||||||
|
app.use(express.json());
|
||||||
|
|
||||||
|
app.post('/sendImageWithBaileysPro', async (req, res) => {
|
||||||
|
if (!sock || !isConnected) {
|
||||||
|
return res.status(400).json({ error: 'Non connecté à WhatsApp' });
|
||||||
|
}
|
||||||
|
|
||||||
|
const {
|
||||||
|
phone, // ex: "33612345678"
|
||||||
|
imageUrl, // ex: "https://example.com/image.jpg"
|
||||||
|
caption, // ex: "Voici une image !"
|
||||||
|
quoted // optionnel : message auquel répondre
|
||||||
|
} = req.body;
|
||||||
|
|
||||||
|
if (!phone || !imageUrl) {
|
||||||
|
return res.status(400).json({ error: 'Paramètres requis manquants (phone, imageUrl)' });
|
||||||
|
}
|
||||||
|
|
||||||
|
const jid = `${phone}@s.whatsapp.net`;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await sock.sendMessage(
|
||||||
|
jid,
|
||||||
|
{
|
||||||
|
image: { url: imageUrl },
|
||||||
|
caption: caption || '',
|
||||||
|
},
|
||||||
|
quoted ? { quoted } : {}
|
||||||
|
);
|
||||||
|
|
||||||
|
res.json({ success: true, to: jid });
|
||||||
|
} catch (e) {
|
||||||
|
console.error('❌ Erreur /sendImageWithBaileysPro :', e);
|
||||||
|
res.status(500).json({ error: e.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user