Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

309
Vistas
Los scripts de hojas de Google se ejecutan correctamente de forma manual, pero la configuración de activadores no funciona

Estoy tratando de enviar mensajes de texto en un disparador de tiempo en una hoja de Google usando Twilio para enviar los textos. Cuando hago clic en el botón Ejecutar, funciona bien, pero cuando configuro un disparador de tiempo, dice que está en estado, está completado pero no funciona. Además, cuando hago clic en Ejecuciones, aparece un error que dice "Excepción: la solicitud falló para https://api.twilio.com devolvió el código 400. Respuesta del servidor truncada: {"código": 21211, "mensaje": "El ' El número de destino no es un número de teléfono válido.", "more_info": "https://www.twilio.com/docs/errors/21211", "status": 400} (use la opción muteHttpExceptions para examinar la respuesta completa)"

Soy 100% nuevo en Java y estoy aprendiendo sobre él, cualquier ayuda sería genial.

Aquí está mi código:

 function RunThisToSendTexts() { function sendSms(to, body) { var messagesUrl = "https://api.twilio.com/2010-04-01/Accounts/AC9837381a431941024fc87xxxxxx/Messages.json"; var payload = { "To": to, "Body" : body, "From" : "+197131999xx" }; var options = { "method" : "post", "payload" : payload }; options.headers = { "Authorization" : "Basic " + Utilities.base64Encode("AC9837381a431941024fcxxxxxxx:22c7dec97dee0cef39exxxxxxx") }; UrlFetchApp.fetch(messagesUrl, options); } function sendAll() { var sheet = SpreadsheetApp.getActiveSheet(); var startRow = 2; // First row of data to process var numRows = sheet.getLastRow() - 1; var dataRange = sheet.getRange(startRow, 1, numRows, 2) var data = dataRange.getValues(); for (i in data) { var row = data[i]; try { response_data = sendSms(row[0], row[1]); status = "sent"; } catch(err) { Logger.log(err); status = "error"; } sheet.getRange(startRow + Number(i), 3).setValue(status); } } sendAll(); }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Intenta escribirlo así:

 function sendSms(to, body) { var messagesUrl = "https://api.twilio.com/2010-04-01/Accounts/AC9837381a431941024fc87xxxxxx/Messages.json"; var payload = { "To": to, "Body" : body, "From" : "+197131999xx" }; var options = { "method" : "post", "payload" : payload }; options.headers = { "Authorization" : "Basic " + Utilities.base64Encode("AC9837381a431941024fcxxxxxxx:22c7dec97dee0cef39exxxxxxx") }; UrlFetchApp.fetch(messagesUrl, options); } function sendAll() { var sheet = SpreadsheetApp.getActiveSheet(); var startRow = 2; // First row of data to process var numRows = sheet.getLastRow() - 1; var dataRange = sheet.getRange(startRow, 1, numRows, 2) var data = dataRange.getValues(); for (i in data) { var row = data[i]; try { response_data = sendSms(row[0], row[1]); status = "sent"; } catch(err) { Logger.log(err); status = "error"; } sheet.getRange(startRow + Number(i), 3).setValue(status); } }

Y simplemente ejecute sendAll();

Prueba sendAll() de esta manera:

 function sendAll() { const ss = SpreadsheetApp.getActive(); const sh = ss.getActiveSheet(); const sr = 2; const data = sh.getRange(sr, 1, sh.getLastRow() - sr + 1, sh.getLastColumn()).getValues(); var status = 'Error' data.forEach((r, i) => { sendSms(r[0], r[1]); status = 'sent'; }); sh.getRange(i + sr, 3).setValue(status); }
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda