Tweet your GPS coordinates via SMS.
Environment:
- Phone: Nokia E71
- PyS60: 2.0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | import sys
import appuifw
import messaging
import positioning
class Worker(object):
def tweet_position(self, position):
def call_back(state):
if state == messaging.ESent:
sys.stdout.write(u"Tweeted!\n")
elif state == messaging.ESendFailed:
sys.stdout.write(u"Something went wrong :(\n")
sms = u"""%s
I am here http://maps.google.com/maps?q=%s,%s
""" % ((appuifw.query(u"tweet @, or cancel to tweet everybody:", "text") or ""),
position['latitude'],position['longitude'])
sys.stdout.write(u"Tweeting position ... ")
messaging.sms_send(u"+8988", sms, callback=call_back) # +8988 -- Twitter number
def get_position(self):
positioning.select_module(270526860) # A-GPS -- you need at least a working GPRS connection
positioning.set_requestors([{"type":"service","format":"application","data":"iamhere"}])
sys.stdout.write(u"Retrieving position ...\n")
return positioning.position()['position']
def main():
worker = Worker()
worker.tweet_position(worker.get_position())
if __name__ == '__main__':
main()
|
Nifty.
Hi. I have a problem implementing this script.
I tried easy_install positioning
I'am using Python 2.5.2 on linux
Thanks, the script 'looks' great! I want to see how it works.
Hi, you need to and S60 smartphone with GPS capabilities first, then install PyS60 on it http://sourceforge.net/projects/pys60/ You'll need to sign the pys60 shell here https://www.symbiansigned.com/app/page/public/openSignedOnline.do to unlock some modules (like positioning in my case) After all this is done, run the script from your phone.
regards, Tim.