blob: 31ad031eb4aae4bb2582fce024c83295acb8164b [file] [log] [blame]
Joe Gregorio292b9b82011-01-12 11:36:11 -05001#!/usr/bin/python2.4
2# -*- coding: utf-8 -*-
3#
4# Copyright 2010 Google Inc. All Rights Reserved.
5
6"""Simple command-line example for Buzz.
7
8Command-line application that retrieves the users
9latest content and then adds a new entry.
10"""
11
12__author__ = 'jcgregorio@google.com (Joe Gregorio)'
13
14from apiclient.discovery import build_from_document
15
16import httplib2
Joe Gregoriof4153422011-03-18 22:45:18 -040017import os
Joe Gregorio292b9b82011-01-12 11:36:11 -050018import pprint
19
Joe Gregorio821e1642011-05-04 10:19:17 -040020def main():
Joe Gregorio292b9b82011-01-12 11:36:11 -050021 http = httplib2.Http()
Joe Gregorio292b9b82011-01-12 11:36:11 -050022
23 # Load the local copy of the discovery document
Joe Gregoriof4153422011-03-18 22:45:18 -040024 f = file(os.path.join(os.path.dirname(__file__), "buzz.json"), "r")
Joe Gregorio292b9b82011-01-12 11:36:11 -050025 discovery = f.read()
26 f.close()
27
28 # Optionally load a futures discovery document
Joe Gregoriof4153422011-03-18 22:45:18 -040029 f = file(os.path.join(os.path.dirname(__file__), "../../apiclient/contrib/buzz/future.json"), "r")
Joe Gregorio292b9b82011-01-12 11:36:11 -050030 future = f.read()
31 f.close()
32
33 # Construct a service from the local documents
Joe Gregorio1ae3e742011-02-25 15:17:14 -050034 service = build_from_document(discovery,
Joe Gregorio292b9b82011-01-12 11:36:11 -050035 base="https://www.googleapis.com/",
Joe Gregorio292b9b82011-01-12 11:36:11 -050036 http=http,
Joe Gregorio821e1642011-05-04 10:19:17 -040037 future=future)
Joe Gregorio292b9b82011-01-12 11:36:11 -050038
Joe Gregorio821e1642011-05-04 10:19:17 -040039 pprint.pprint(service.activities().search(q='lady gaga').execute())
Joe Gregorio292b9b82011-01-12 11:36:11 -050040
Joe Gregorio292b9b82011-01-12 11:36:11 -050041
42if __name__ == '__main__':
Joe Gregorio821e1642011-05-04 10:19:17 -040043 main()