Advertisement
ivan_carrotquest

Untitled

Sep 1st, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.23 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. # Отправка SMS на чистом Python через sms-шлюз SMSPILOT.RU
  3. import requests
  4. import xml.etree.ElementTree as ET
  5. import urllib
  6. import json
  7. import re
  8.  
  9. def run(event, context):
  10.     user = json.loads(event['body']['user'])
  11.     event = json.loads(event['body']['event'])
  12.     userid = str(user['id'])
  13.     phone = str(user['props'].get('$phone', ''))
  14.     phoneFormat = re.sub("\D", "", phone) # номер телефона в международном формате
  15.     text = 'Спасибо за обращение в СанСочи! Совсем скоро мы перезвоним вам!'; # текст сообщения
  16.     sender = 'INFORM'; #  имя отправителя из списка https://www.smspilot.ru/my-sender.php
  17.     # !!! Замените API-ключ на свой https://www.smspilot.ru/my-settings.php#api
  18.     apikey = '08P1PYH5AMMLVZK9V88B7JVA331MWA4Y4Y8RC7P79PG3BR00574Z611KS946A8KE';
  19.    
  20.     #url = "http://smspilot.ru/api.php?send=%s&to=%s&from=%s&apikey=%s&format=json" % (text, phoneFormat, sender, apikey )
  21.     r = requests.post("http://smspilot.ru/api.php?send=" + text + "&to=" +str(phoneFormat) + "&from=" + sender + "&apikey=" + apikey + "&format=json")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement