Answer the question
In order to leave comments, you need to log in
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
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/
sms.ru, which apparently closed.
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" с цепочек
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question