blob: 029b74a4d1896ed1d03aa298a8db7f44436e6cab [file] [log] [blame]
Joe Gregorio0802a172010-10-26 16:23:00 -04001#!/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
8Command-line application that sets the users
9current location.
10"""
11
12__author__ = 'jcgregorio@google.com (Joe Gregorio)'
13
14
15from apiclient.discovery import build
16
17import httplib2
18import pickle
19
20# Uncomment to get detailed logging
21# httplib2.debuglevel = 4
22
Joe Gregorioaf276d22010-12-09 14:26:58 -050023
Joe Gregorio0802a172010-10-26 16:23:00 -040024def 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 Gregorioaf276d22010-12-09 14:26:58 -050036 "kind": "latitude#location",
37 "latitude": 37.420352,
38 "longitude": -122.083389,
39 "accuracy": 130,
40 "altitude": 35
Joe Gregorio0802a172010-10-26 16:23:00 -040041 }
42 }
43 print p.currentLocation().insert(body=body).execute()
44
45if __name__ == '__main__':
46 main()