blob: 92be46d63ef79b29f44dd5f408fbcd77849b817a [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 Gregorio00cf1d92010-09-27 09:22:03 -040018httplib2.debuglevel = 4
Joe Gregorio845a5452010-09-08 13:50:34 -040019import pickle
Joe Gregorio48d361f2010-08-18 13:19:21 -040020
21
22def main():
Joe Gregorioa2f56e72010-09-09 15:15:56 -040023 f = open("buzz.dat", "r")
Joe Gregorio845a5452010-09-08 13:50:34 -040024 credentials = pickle.loads(f.read())
25 f.close()
26
27 http = httplib2.Http()
28 http = credentials.authorize(http)
29
Joe Gregorio00cf1d92010-09-27 09:22:03 -040030 p = build("buzz", "v1", http=http, developerKey='AIzaSyDRRpR3GS1F1_jKNNM9HCNd2wJQyPG3oN0')
Joe Gregorio48d361f2010-08-18 13:19:21 -040031 activities = p.activities()
Joe Gregorioc5c5a372010-09-22 11:42:32 -040032 activitylist = activities.list(max_results='2', scope='@self', userId='@me').execute()
Joe Gregorio48d361f2010-08-18 13:19:21 -040033 print activitylist['items'][0]['title']
Joe Gregorioc5c5a372010-09-22 11:42:32 -040034 activitylist = activities.list_next(activitylist).execute()
35 print activitylist['items'][0]['title']
36
Joe Gregorio48d361f2010-08-18 13:19:21 -040037 activities.insert(userId='@me', body={
38 'title': 'Testing insert',
39 'object': {
Joe Gregorio41cf7972010-08-18 15:21:06 -040040 'content': u'Just a short note to show that insert is working. ☄',
Joe Gregorio48d361f2010-08-18 13:19:21 -040041 'type': 'note'}
42 }
Joe Gregorio5f087cf2010-09-20 16:08:07 -040043 ).execute()
Joe Gregorio48d361f2010-08-18 13:19:21 -040044
45if __name__ == '__main__':
46 main()