I
I
Ilya Pankov2016-02-10 22:25:11
PHP
Ilya Pankov, 2016-02-10 22:25:11

How to send SMS notifications from your site to yourself?

Hey!
Started integrating SMS notifications into the website. The algorithm is terribly simple: the user bought - on e-mail notifications - SMS notifications to the programmer. I chose sms.ru, which apparently closed.
What other services are available for sending free sms to one number?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey Kobyshev, 2016-02-10
@yokotoka

Is SMS important in the age of smartphones and unlimited internet? There is an opinion that it is much better to do a telegram or slack bot for this.
It becomes elementary - one http-request.
In slack it's chat.postMessage, in telegram it's something similar.
https://api.slack.com/
https://core.telegram.org/

A
Andrey Burov, 2016-02-10
@BuriK666

Send by mail and let it receive email on the phone.

A
Alexander Taratin, 2016-02-10
@Taraflex

sms.ru, which apparently closed.

Yes, he seems to be alive.
In Google Docs, you can create a table to which you can attach a Googlescript, which will process all new letters according to the "crown" (configured in the gs editor). For example, such a notification on sms works for me.
function getLastMessageBody(thread){
  var msgs = thread.getMessages();
  var msg = msgs[msgs.length - 1].getBody();
  return (/<em>(.+)<\/em>/i).exec(msg.replace(/\s+/gim,' '))[1];
}

function trimForSMS(text, mchars){
  mchars = mchars || 0;
  text = text.trim();
  var maxLetters = ( /^[a-zA-Z0-9\s\^\[\]\(\)\/\*\+\-\=\|\{\}\%\,\$\#\@\&\!\?\.\,\`\~\;\:\_\<\>\"]*$/.test(text) ? 160 : 70 ) - 12 - mchars;
  return text.substring(0,maxLetters).trim();
}

function my_notification() 
{  
  var labels = GmailApp.getUserLabelByName('SMSnotify');
  
  if(labels)
  {
    var threads = labels.getThreads(); 
    
    if(threads.length > 0)
    {
      for(i in threads)
      {
        var cthread = threads[i];
        
        var text = cthread.getFirstMessageSubject();
        
        if(text[0] == 'R' && text[1] == 'e' && text[2] == ':')
        {
          text = text.substring(3);
        }
        text = trimForSMS(text);      
        
        if(text == 'Новое сообщение в заказе на FL.ru')
        {          
          text = 'FL.ru: ' + trimForSMS(getLastMessageBody(cthread), 7);
        }
        
        UrlFetchApp.fetch('http://sms.ru/sms/send?api_id=<ваш ключ>&to=9176696749&text=' + encodeURIComponent(text));
      }
      
      labels.removeFromThreads(threads); //снимаем метки "SMSnotify" с цепочек
    }
  }
}

The "SMSnotify" label is attached to all new emails addressed directly to me in the gmail filter settings.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question