def main(): storage = Storage('latitude.dat') credentials = storage.get() if credentials is None or credentials.invalid == True: auth_discovery = build("latitude", "v1").auth_discovery() flow = FlowThreeLegged(auth_discovery, # You MUST have a consumer key and secret tied to a # registered domain to use the latitude API. # # https://www.google.com/accounts/ManageDomains consumer_key='svetsen.homeip.net', consumer_secret='lzhGCgXu33_hj33YN4LYvL98', user_agent='google-api-client-python-latitude/1.0', domain='svetsen.homeip.net', scope='https://www.googleapis.com/auth/latitude', xoauth_displayname='Google API Latitude Example', location='history', granularity='city' ) credentials = run(flow, storage) http = httplib2.Http() http = credentials.authorize(http) service = build("latitude", "v1", http=http) body = { "data": { "kind": "latitude#location", "timestampMs": "%d" % (time.time()-12*60*60)*1000 } } print service.location().list().execute()
def __init__(self): # Connect to Latitude storage = Storage('latitude.dat') credentials = storage.get() if credentials is None or credentials.invalid == True: auth_discovery = build("latitude", "v1").auth_discovery() flow = FlowThreeLegged(auth_discovery, # You MUST have a consumer key and secret tied to a # registered domain to use the latitude API. # # https://www.google.com/accounts/ManageDomains consumer_key='maleadt.be', consumer_secret='Yh0qdTQ-pHGQiyguyINr64WK', user_agent='efficient-latitude/0.1', domain='maleadt.be', scope='https://www.googleapis.com/auth/latitude', xoauth_displayname='Efficient Latitude', location='all', granularity='best' ) # Work around https://code.google.com/p/google-api-python-client/issues/detail?id=34 while len(sys.argv) > 1: sys.argv.pop() credentials = run(flow, storage) if credentials is None or credentials.invalid == True: raise Exception("Invalid Latitude credentials") http = httplib2.Http() http = credentials.authorize(http) self.service = build("latitude", "v1", http=http)
def main(): signal.alarm(47) storage = Storage('latitude.dat') credentials = storage.get() if credentials is None or credentials.invalid == True: auth_discovery = build("latitude", "v1").auth_discovery() flow = FlowThreeLegged( auth_discovery, # You MUST have a consumer key and secret tied to a # registered domain to use the latitude API. # # https://www.google.com/accounts/ManageDomains consumer_key='west.spy.net', consumer_secret='kF52E2QkcMYeWI5JBxUdqHkE', user_agent='google-api-client-python-latitude/1.0', domain='west.spy.net', scope='https://www.googleapis.com/auth/latitude', xoauth_displayname='Google API Latitude Example', location='all', granularity='best') credentials = run(flow, storage) http = httplib2.Http() http = credentials.authorize(http) service = build("latitude", "v1", http=http) more = True max_time = "" args = {'max_results': '1000', 'granularity': 'best'} # See if we're picking up from somewhere... try: lastKey = list( DB.view('_all_docs', limit=1, descending=True, startkey='9'))[0].id args['min_time'] = lastKey print "Resuming since", lastKey except IndexError: print "Not resuming." while more: r = service.location().list(**args).execute()['items'] store(r) more = len(r) == 1000 print "Got %d records from %s - %s" % (len(r), ts(r[-1]), ts(r[0])) args['max_time'] = r[-1]['timestampMs']
def main(): signal.alarm(47) storage = Storage('latitude.dat') credentials = storage.get() if credentials is None or credentials.invalid == True: auth_discovery = build("latitude", "v1").auth_discovery() flow = FlowThreeLegged(auth_discovery, # You MUST have a consumer key and secret tied to a # registered domain to use the latitude API. # # https://www.google.com/accounts/ManageDomains consumer_key='west.spy.net', consumer_secret='kF52E2QkcMYeWI5JBxUdqHkE', user_agent='google-api-client-python-latitude/1.0', domain='west.spy.net', scope='https://www.googleapis.com/auth/latitude', xoauth_displayname='Google API Latitude Example', location='all', granularity='best' ) credentials = run(flow, storage) http = httplib2.Http() http = credentials.authorize(http) service = build("latitude", "v1", http=http) more = True max_time = "" args = {'max_results': '1000', 'granularity': 'best'} # See if we're picking up from somewhere... try: lastKey = list(DB.view('_all_docs', limit=1, descending=True, startkey='9'))[0].id args['min_time'] = lastKey print "Resuming since", lastKey except IndexError: print "Not resuming." while more: r = service.location().list(**args).execute()['items'] store(r) more = len(r) == 1000 print "Got %d records from %s - %s" % (len(r), ts(r[-1]), ts(r[0])) args['max_time'] = r[-1]['timestampMs']
def main(): storage = Storage('latitude.dat') credentials = storage.get() if credentials is None or credentials.invalid == True: auth_discovery = build("latitude", "v1").auth_discovery() flow = FlowThreeLegged(auth_discovery, # You MUST have a consumer key and secret tied to a # registered domain to use the latitude API. # # https://www.google.com/accounts/ManageDomains consumer_key=settings.GOOGLE_API_KEY, consumer_secret=settings.GOOGLE_API_SECRET, user_agent='google-api-client-python-latitude/1.0', domain=settings.GOOGLE_API_KEY, scope='https://www.googleapis.com/auth/latitude', xoauth_displayname='Google API Latitude Example', location='current', granularity='city' ) print 'monkey' credentials = run(flow, storage) http = httplib2.Http() http = credentials.authorize(http) service = build("latitude", "v1", http=http) body = { "data": { "kind": "latitude#location", "latitude": 37.420352, "longitude": -122.083389, "accuracy": 130, "altitude": 35 } } print service.currentLocation().insert(body=body).execute()
def main(): storage = Storage('latitude.dat') credentials = storage.get() if credentials is None or credentials.invalid == True: auth_discovery = build("latitude", "v1").auth_discovery() flow = FlowThreeLegged( auth_discovery, # You MUST have a consumer key and secret tied to a # registered domain to use the latitude API. # # https://www.google.com/accounts/ManageDomains consumer_key='REGISTERED DOMAIN NAME', consumer_secret='KEY GIVEN DURING REGISTRATION', user_agent='google-api-client-python-latitude/1.0', domain='REGISTERED DOMAIN NAME', scope='https://www.googleapis.com/auth/latitude', xoauth_displayname='Google API Latitude Example', location='current', granularity='city') credentials = run(flow, storage) http = httplib2.Http() http = credentials.authorize(http) service = build("latitude", "v1", http=http) body = { "data": { "kind": "latitude#location", "latitude": 37.420352, "longitude": -122.083389, "accuracy": 130, "altitude": 35 } } print service.currentLocation().insert(body=body).execute()