blob: de871eb83251866ca6f1966d51927dc49025a49d [file] [log] [blame]
Joe Gregorio48d361f2010-08-18 13:19:21 -04001#!/usr/bin/python2.4
2# -*- coding: utf-8 -*-
3#
4# Copyright 2010 Google Inc. All Rights Reserved.
5
Joe Gregorio845a5452010-09-08 13:50:34 -04006"""Simple command-line example for Buzz.
Joe Gregorio48d361f2010-08-18 13:19:21 -04007
Joe Gregorio845a5452010-09-08 13:50:34 -04008Command-line application that retrieves the users
9latest content and then adds a new entry.
Joe Gregorio48d361f2010-08-18 13:19:21 -040010"""
11
12__author__ = 'jcgregorio@google.com (Joe Gregorio)'
13
Joe Gregorio48d361f2010-08-18 13:19:21 -040014
15from apiclient.discovery import build
16
17import httplib2
Joe Gregorio845a5452010-09-08 13:50:34 -040018import pickle
Joe Gregorio48d361f2010-08-18 13:19:21 -040019
20
21def main():
Joe Gregorioa2f56e72010-09-09 15:15:56 -040022 f = open("buzz.dat", "r")
Joe Gregorio845a5452010-09-08 13:50:34 -040023 credentials = pickle.loads(f.read())
24 f.close()
25
26 http = httplib2.Http()
27 http = credentials.authorize(http)
28
Joe Gregorio41cf7972010-08-18 15:21:06 -040029 p = build("buzz", "v1", http=http)
Joe Gregorio48d361f2010-08-18 13:19:21 -040030 activities = p.activities()
31 activitylist = activities.list(scope='@self', userId='@me')
32 print activitylist['items'][0]['title']
33 activities.insert(userId='@me', body={
34 'title': 'Testing insert',
35 'object': {
Joe Gregorio41cf7972010-08-18 15:21:06 -040036 'content': u'Just a short note to show that insert is working. ☄',
Joe Gregorio48d361f2010-08-18 13:19:21 -040037 'type': 'note'}
38 }
39 )
40
41if __name__ == '__main__':
42 main()