Joe Gregorio | 0802a17 | 2010-10-26 16:23:00 -0400 | [diff] [blame] | 1 | #!/usr/bin/python2.4 |
| 2 | # -*- coding: utf-8 -*- |
| 3 | # |
| 4 | # Copyright 2010 Google Inc. All Rights Reserved. |
| 5 | |
| 6 | """Simple command-line example for Latitude. |
| 7 | |
| 8 | Command-line application that sets the users |
| 9 | current location. |
| 10 | """ |
| 11 | |
| 12 | __author__ = 'jcgregorio@google.com (Joe Gregorio)' |
| 13 | |
| 14 | |
| 15 | from apiclient.discovery import build |
| 16 | |
| 17 | import httplib2 |
| 18 | import pickle |
| 19 | |
| 20 | # Uncomment to get detailed logging |
| 21 | # httplib2.debuglevel = 4 |
| 22 | |
Joe Gregorio | af276d2 | 2010-12-09 14:26:58 -0500 | [diff] [blame] | 23 | |
Joe Gregorio | 0802a17 | 2010-10-26 16:23:00 -0400 | [diff] [blame] | 24 | def main(): |
| 25 | f = open("latitude.dat", "r") |
| 26 | credentials = pickle.loads(f.read()) |
| 27 | f.close() |
| 28 | |
| 29 | http = httplib2.Http() |
| 30 | http = credentials.authorize(http) |
| 31 | |
| 32 | p = build("latitude", "v1", http=http) |
| 33 | |
| 34 | body = { |
| 35 | "data": { |
Joe Gregorio | af276d2 | 2010-12-09 14:26:58 -0500 | [diff] [blame] | 36 | "kind": "latitude#location", |
| 37 | "latitude": 37.420352, |
| 38 | "longitude": -122.083389, |
| 39 | "accuracy": 130, |
| 40 | "altitude": 35 |
Joe Gregorio | 0802a17 | 2010-10-26 16:23:00 -0400 | [diff] [blame] | 41 | } |
| 42 | } |
| 43 | print p.currentLocation().insert(body=body).execute() |
| 44 | |
| 45 | if __name__ == '__main__': |
| 46 | main() |