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 | |
| 23 | def main(): |
| 24 | f = open("latitude.dat", "r") |
| 25 | credentials = pickle.loads(f.read()) |
| 26 | f.close() |
| 27 | |
| 28 | http = httplib2.Http() |
| 29 | http = credentials.authorize(http) |
| 30 | |
| 31 | p = build("latitude", "v1", http=http) |
| 32 | |
| 33 | body = { |
| 34 | "data": { |
| 35 | "kind":"latitude#location", |
| 36 | "latitude":37.420352, |
| 37 | "longitude":-122.083389, |
| 38 | "accuracy":130, |
| 39 | "altitude":35 |
| 40 | } |
| 41 | } |
| 42 | print p.currentLocation().insert(body=body).execute() |
| 43 | |
| 44 | if __name__ == '__main__': |
| 45 | main() |