blob: 411ad27ebd5faab46c6079676ee4edea28cc1893 [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
Joe Gregorio292b9b82011-01-12 11:36:11 -050028 # Construct a service from the local documents
Joe Gregorio1ae3e742011-02-25 15:17:14 -050029 service = build_from_document(discovery,
Joe Gregorio292b9b82011-01-12 11:36:11 -050030 base="https://www.googleapis.com/",
Joe Gregorio57e6e022011-10-28 08:13:01 -040031 http=http)
Joe Gregorio292b9b82011-01-12 11:36:11 -050032
Joe Gregorio821e1642011-05-04 10:19:17 -040033 pprint.pprint(service.activities().search(q='lady gaga').execute())
Joe Gregorio292b9b82011-01-12 11:36:11 -050034
Joe Gregorio292b9b82011-01-12 11:36:11 -050035
36if __name__ == '__main__':
Joe Gregorio821e1642011-05-04 10:19:17 -040037 main()