2016-11-12 8 views
0

私のtwilio番号を伝え、それをスクリプト用の入力として使用したいと考えています。私はPythonでtwilio経由でメッセージを送信できますが、何とか受信できるようにしたいと考えています。pythonスクリプトの入力として受け取ったTwilioのテキストメッセージを使用します。

のPython 3.4 Twilioのトライアルアカウント

+0

twilioを使ってテキストメッセージの電子メールアドレスを検索し、mailgunのような別のユーティリティを使って実際にメッセージを送受信することで、これはもっと簡単になります – user2682863

+0

これについて詳細に説明できますか? twilioとこのエリアに新しいです –

答えて

0

これを行うには、私が知っている最も簡単な方法はとても

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 

ようTwilioを使ってキャリアを検索して、mailgun https://documentation.mailgun.com/

0
と/受信メールを送信することです

Twilioデベロッパーエバンジェリスト

あなたのTwilio番号がSMSメッセージを受信すると、TwilioはWebhook、HTTPリクエストをメッセージの詳細すべてを含むあなたの選択したURLに送信できます。これを使用してメッセージを受信して​​返信することができます。

には本当に役立つと思う素晴らしいガイドがあります。

関連する問題