Tuesday, April 8, 2014

How to Send a Cell Phone a Text Message With a Python Script


1. Sign up for a Gmail account by filling out the form.
2. Download the latest version of the Google library for Python.
3. Right click the zip file and select 'Extract.' A dialog box will pop up requesting a target location to extract the zip file. Select the 'Documents' directory and click 'Extract.'
4. Launch the Microsoft command prompt. Click 'Start,' 'Run,' then type 'CMD.EXE' and press 'Enter.'
5. Move to the library directory. At the command prompt, type 'cd c:\Documents\gdata-2.0.12' then press 'Enter.'
6. Build and install the library. At the command prompt, type 'python setup.py build' then press 'Enter.' Type 'python.py install' then press 'Enter.'
7. Launch the Python line editor. At the command prompt, type 'python' then press 'Enter.' The prompt will change to '>>>' to indicate that the Python editor is active.
8. Import the Gmail library and text message module. At the command prompt, type 'import libgmail' then press 'Enter.' Type 'from TextMessaging import *' then press 'Enter.'
9. Register the sender information. At the command prompt, type:sender = Sender('
', '
')Replace
with the login name from the Gmail account. Replace
with the password for the Gmail account then press 'Enter.'
10. Register the text message information. At the command prompt, type:smsMessage = TextMessage('
', '
')Replace
with the subject of the message. Replace
with the body of the message then press 'Enter.'
11. Register the carrier data. At the command prompt, type:CARRIERS = {'Alltel':'alltelmessage.com','ATT':'mobile.mycingular.com','Rogers':'pcs.rogers.com','Sprint':'messaging.sprintpcs.com','tMobile':'t-mobile.net','Telus':'msg.telus.com','Verizon':'vtext.com'}then press 'Enter.'
12. Register the receiver of the text message. At the command prompt, type:receiver = Receiver('', '
')Replace with the phone number of the person who will receive the text message. Replace
with the name of the carrier the person uses. Make sure to type the carrier name exactly the way it appears in the step where the carrier was registered. The carrier name is case sensitive.
13. Send the message. At the command prompt, type:sender.sendMessage(receiver, smsMessage)then press 'Enter.'

No comments:

Post a Comment