Joe Gregorio | 292b9b8 | 2011-01-12 11:36:11 -0500 | [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 Buzz. |
| 7 | |
| 8 | Command-line application that retrieves the users |
| 9 | latest content and then adds a new entry. |
| 10 | """ |
| 11 | |
| 12 | __author__ = 'jcgregorio@google.com (Joe Gregorio)' |
| 13 | |
| 14 | from apiclient.discovery import build_from_document |
| 15 | |
| 16 | import httplib2 |
Joe Gregorio | f415342 | 2011-03-18 22:45:18 -0400 | [diff] [blame] | 17 | import os |
Joe Gregorio | 292b9b8 | 2011-01-12 11:36:11 -0500 | [diff] [blame] | 18 | import pprint |
| 19 | |
Joe Gregorio | 821e164 | 2011-05-04 10:19:17 -0400 | [diff] [blame] | 20 | def main(): |
Joe Gregorio | 292b9b8 | 2011-01-12 11:36:11 -0500 | [diff] [blame] | 21 | http = httplib2.Http() |
Joe Gregorio | 292b9b8 | 2011-01-12 11:36:11 -0500 | [diff] [blame] | 22 | |
| 23 | # Load the local copy of the discovery document |
Joe Gregorio | f415342 | 2011-03-18 22:45:18 -0400 | [diff] [blame] | 24 | f = file(os.path.join(os.path.dirname(__file__), "buzz.json"), "r") |
Joe Gregorio | 292b9b8 | 2011-01-12 11:36:11 -0500 | [diff] [blame] | 25 | discovery = f.read() |
| 26 | f.close() |
| 27 | |
Joe Gregorio | 292b9b8 | 2011-01-12 11:36:11 -0500 | [diff] [blame] | 28 | # Construct a service from the local documents |
Joe Gregorio | 1ae3e74 | 2011-02-25 15:17:14 -0500 | [diff] [blame] | 29 | service = build_from_document(discovery, |
Joe Gregorio | 292b9b8 | 2011-01-12 11:36:11 -0500 | [diff] [blame] | 30 | base="https://www.googleapis.com/", |
Joe Gregorio | 57e6e02 | 2011-10-28 08:13:01 -0400 | [diff] [blame^] | 31 | http=http) |
Joe Gregorio | 292b9b8 | 2011-01-12 11:36:11 -0500 | [diff] [blame] | 32 | |
Joe Gregorio | 821e164 | 2011-05-04 10:19:17 -0400 | [diff] [blame] | 33 | pprint.pprint(service.activities().search(q='lady gaga').execute()) |
Joe Gregorio | 292b9b8 | 2011-01-12 11:36:11 -0500 | [diff] [blame] | 34 | |
Joe Gregorio | 292b9b8 | 2011-01-12 11:36:11 -0500 | [diff] [blame] | 35 | |
| 36 | if __name__ == '__main__': |
Joe Gregorio | 821e164 | 2011-05-04 10:19:17 -0400 | [diff] [blame] | 37 | main() |