Using with just Django
-
Make sure you have installed the dj_simple_sms app in your django project
-
In your settings.py file, add:
SMS_HANDLERS = ( 'dj_simple_sms.sample_sms_handler', )
-
Start your django app using
python manage.py runserver
-
Go the the admin page, and find the 'Devices' model
-
Click it, then add a new device (call it 'python sms' or anything you want)
-
Back in the list view, you should now see a random key for that device. Copy it.
-
In another terminal window, go to the
sms_pipeline
folder -
Open up the file
pipeline.py
-
Fill in the
DJANGO_KEY
setting with the key you copied from the admin panel -
Check the
DJANGO_URL
setting to make sure that it matches the django app you have running -
Install the requirements for the sms_pipeline:
pip install -r requirements.txt
-
Run
python pipeline.py terminal django
-
You should see some output indicating that things have started up, and a prompt, "To: "
-
Try sending a message from the terminal, by manually entering data for the "To:", "From:", and "Body:" fields. Watch the terminal that django is running in - you should see your message appear there.
-
Go again to your django admin, and create a new SMS. When you click save, you should see it appear in the terminal in which you are running
pipeline.py
(note that this may get mixed up with the "To:, From:" prompts, but don't worry about it). -
Hooray! To use your own function to do something interesting with a received SMS, write a function similar to the
sample_sms_handler
and add a string with its python path to the SMS_HANDLERS tuple. -
To quit the
pipeline.py
program, hitCtrl-C
Using with just Android
- Go to the folder containing the
adb
command and run./adb -d forward tcp:7800 tcp:7800
. This sets up your computer to forward all communication on port 7800 of your computer to port 7800 of the android device. - On the android device, start the SMSToolkit program. Don't quit it!
- Go to the
sms_pipeline
folder, and runpython pipeline.py android terminal
. - If there are no error messages, try sending a SMS from the terminal to your own phone number. Then try sending one back. Hooray!
- To quit the main program, press
Ctl-C
Using with Django and Android
If:
python pipeline.py android terminal
is workingpython pipeline.py terminal django
is working
Then connecting your android phone to your Django application is as simple as:
python pipeline.py android django