crea un script en JS que genere un trigger en una applet de IFTTT a partir de un…
- User
crea un script en JS que genere un trigger en una applet de IFTTT a partir de un webhook, la documentacion es esta: Your key is: RgS55pXXwUZoL3rtmqUvy To trigger an Event with 3 JSON values Make a POST or GET web request to:
https://maker.ifttt.com/trigger/test/with/key/RgS55pXXwUZoL3rtmqUvy With an optional JSON body of:
{ "value1" : "1", "value2" : "2", "value3" : "2" }
The data is completely optional, and you can also pass value1, value2, and value3 as query parameters or form variables. This content will be passed on to the action in your Applet.
You can also try it with curl from a command line.
curl -X POST -H "Content-Type: application/json" -d '{"value1":"1","value2":"2","value3":"2"}' https://maker.ifttt.com/trigger/test/with/key/RgS55pXXwUZoL3rtmqUvy
- Assistant
Aquí tienes un ejemplo de un script en JavaScript que puedes utilizar para generar un trigger en una applet de IFTTT a partir de un webhook:
// Primero, asegúrate de tener instalado 'node-fetch' ejecutando 'npm install node-fetch' en tu terminal const fetch = require('node-fetch'); // Función para enviar datos a través de un webhook a IFTTT async function triggerIFTTTWebhook(event, key, value1 = '', value2 = '', value3 = '') { const webhookURL = `https://maker.ifttt.com/trigger/${event}/with/key/${key}`; const response = await fetch(webhookURL, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ value1, value2, value3, }), }); if (response.ok) { console.log('¡Evento disparado con éxito!'); } else { console.error('Hubo un error al disparar el evento en IFTTT.'); } } // Ejemplo de cómo usar la función triggerIFTTTWebhook const event = 'test'; const key = 'RgS55pXXwUZoL3rtmqUvy'; const value1 = '1'; const value2 = '2'; const value3 = '2'; triggerIFTTTWebhook(event, key, value1, value2, value3);