我希望能够发送我的twilio号码并将其用作我脚本的输入。我可以通过twilio用python发送消息,但希望能够以某种方式接收它们。
Python 3.4 Twilio试用帐户
答案 0 :(得分:0)
我知道这样做的最简单方法是使用Twilio查找运营商
from twilio.rest.lookups import TwilioLookupsClient
client = TwilioLookupsClient(TWILIO_SID, TWILIO_API)
twilio_number = client.phone_numbers.get(number, include_carrier_info=True, country_code="US")
carrier_name = twilio_number.carrier['name']
carrier_lib = {'Golden Telecom': 'sms.goldentele.com', 'Rogers Canada': 'pcs.rogers.com',
'Western Wireless': 'cellularonewest.com', 'Cingular (Now AT&T)': 'txt.att.net',
'Boost Mobile': 'myboostmobile.com', 'Cellular South': 'csouth1.com',
'Bell Mobility': 'txt.bellmobility.ca', 'Fido': 'fido.ca', 'Comcast': 'comcastpcs.textmsg.com',
'Virgin Mobile': 'vmobl.com', 'Southwestern Bell': 'email.swbw.com',
'Corr Wireless Communications': 'corrwireless.net', 'Helio': 'messaging.sprintpcs.com',
'T-Mobile': 'tmomail.net', 'Metro PCS': 'mymetropcs.com', 'US West': 'uswestdatamail.com',
"President's Choice": 'txt.bell.ca', 'ACS Wireless': 'paging.acswireless.com', 'Tracfone': 'txt.att.net',
'Carolina West Wireless': 'cwwsms.com', 'Virgin Mobile Canada': 'vmobile.ca', 'Qwest': 'qwestmp.com',
'Public Service Cellular': 'sms.pscel.com', 'Cellular One': 'mobile.celloneusa.com',
'Rogers AT&T Wireless': 'pcs.rogers.com', 'Houston Cellular': 'text.houstoncellular.net',
'Centennial Wireless': 'cwemail.com', 'Metrocall': 'page.metrocall.com', 'Clearnet': 'msg.clearnet.com',
'AT&T': 'txt.att.net', 'Verizon': 'vtext.com', '3 River Wireless': 'sms.3rivers.net',
'BPL Mobile': 'bplmobile.com', 'Triton': 'tms.suncom.com',
'Surewest Communicaitons': 'mobile.surewest.com', 'MTS': 'text.mtsmobility.com',
'Alltel': 'message.alltel.com', 'Bell Mobility (Canada)': 'txt.bell.ca', 'Unicel': 'utext.com',
'Inland Cellular Telephone': 'inlandlink.com', 'Solo Mobile': 'txt.bell.ca',
'CenturyTel': 'messaging.centurytel.net', 'Bell Canada': 'bellmobility.ca',
'Idea Cellular': 'ideacellular.net', 'Sprint': 'messaging.sprintpcs.com',
'Illinois Valley Cellular': 'ivctext.com', 'Metrocall 2-way': 'my2way.com',
'US Cellular': 'email.uscc.net', 'Satellink': 'satellink.net', 'Dobson': 'mobile.dobson.net',
'Edge Wireless': 'sms.edgewireless.com', 'Nextel': 'messaging.nextel.com', 'MCI': 'pagemci.com',
'Microcell': 'fido.ca', 'OnlineBeep': 'onlinebeep.net', 'PCS One': 'pcsone.net',
'Sumcom': 'tms.suncom.com', 'Telus': 'msg.telus.com', 'Blue Sky Frog': 'blueskyfrog.com',
'West Central Wireless': 'sms.wcc.net', 'Mobilcomm': 'mobilecomm.net',
'Bluegrass Cellular': 'sms.bluecell.com', 'Midwest Wireless': 'clearlydigital.com',
"Sprint Spectrum, L.P.": 'messaging.sprintpcs.com'}
carrier_domain = carrier_lib[carrier_name] # Should implement a better lookup method, often times the carrier names vary slightly and will raise a KeyError
phone_num_email_addres = str(10_digit_num) + "@" + carrier_domain
然后使用mailgun https://documentation.mailgun.com/
发送/接收电子邮件答案 1 :(得分:0)
Twilio开发者传道者在这里。
当您的Twilio号码收到短信时,您可以让Twilio向您选择的URL发送一个webhook(一个HTTP请求),其中包含有关该消息的所有详细信息。您可以使用它来接收消息并回复它。
how to receive SMS messages using Python and Flask有一个很好的指南,我认为可以真正帮助你。