Advertisement
Sofia93

Untitled

Nov 18th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. const admin = require('firebase-admin');
  2.  
  3.  
  4.  
  5. /* Twilio*/
  6. const ACCOUNTSID = 'ACae68ce6b920d8ffc048655ecb89d5dbf';
  7. const AUTHTOKEN = '6d95b443fac1a60ef53a84dcec5b6813';
  8.  
  9.  
  10. admin.initializeApp();
  11. const app = express();
  12.  
  13. var twilio = require('twilio'),
  14. var client = new twilio('ACCOUNTSID', 'AUTHTOKEN'),
  15. cronJob = require('cron').CronJob;
  16.  
  17. var Firebase = require('firebase'),
  18. usersRef = new Firebase('https://dengue-chat.firebaseio.com/users/');
  19.  
  20. var numbers = [];
  21. usersRef.on('phoneNumber', function(snapshot) {
  22. //numbers.push( snapshot.val() );
  23. numbers.pull(shapshot.val());
  24. //console.log( 'Added number ' + snapshot.val() );
  25. });
  26.  
  27. var textJob = new cronJob( '10 16 * * *', function(){
  28. for( var i = 0; i < numbers.length; i++ ) {
  29. client.messages.create( { to:numbers[i], from:'+15129801752', body:'Hello! Hope you’re having a good day.'}, function( err, data ) {
  30. console.log( data.body );
  31. });
  32. }
  33. }, null, true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement