Created
January 12, 2017 21:26
-
-
Save MarcusHurney/aa2d963e2ffce355ba1e7fb15f304cb2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async.each(myContacts, function(contact, messageToSend, callback) { | |
const message = { | |
from: "+18442849820", | |
to: `+1${contact.number}`, | |
text: messageToSend, | |
callbackUrl: 'https://happie-match.herokuapp.com/messageCallback' | |
}; | |
client.Message.send(message) | |
.then(function(message) { | |
console.log("Message sent with ID " + message.id); | |
callback(); | |
}) | |
.catch(function(err) { | |
console.log(err.message); | |
callback(err); | |
}); | |
}, function(err) { | |
if( err ) { | |
// One of the iterations produced an error. | |
// All processing will now stop. | |
console.log('There was an error sending SMS'); | |
console.log(err); | |
} else { | |
console.log('All SMS sent'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment