script for messaging location

This commit is contained in:
prince 2018-10-03 11:18:06 +05:30
parent dbb9917e42
commit f28d94eb11
2 changed files with 20 additions and 0 deletions

6
SmsYourLocation/HowTo.md Normal file
View File

@ -0,0 +1,6 @@
<p>this is small python script to send sms to your loved ones....especially for those have very caring mother like mine</p>
<p>so you can run this script as cron job and it will SMS your currrent location to number you want (note: it should be registered with TWILO)</p>
<p><b>NOTE:you need to make a account in twilo. if you are going to use paid one you will have more options like multiple numbers extra....</b></p>

View File

@ -0,0 +1,14 @@
import urllib3
import json
http = urllib3.PoolManager()
r = http.request('GET', 'http://ipinfo.io/json')
data = json.loads(r.data.decode('utf-8'))
city=data['city']
loc=data['loc']
print(city,loc)
from twilio.rest import Client
client = Client("TWILO SSID", "AUTH TOKEN")
client.messages.create(to="PHONE NO YOU WANT TO SEND SMS",
from_="YOUR TWILLO PHONE NUMBER",
body="hi amma i am in "+city+" now and my cordinates are " +loc)