Joe Gregorio | 652898b | 2011-05-02 21:07:43 -0400 | [diff] [blame] | 1 | # version: v1 |
| 2 | # scope: https://www.googleapis.com/auth/buzz |
| 3 | # title: Simple command-line sample for Buzz. |
| 4 | # description: Command-line application that retrieves the users latest content and then adds a new entry. |
| 5 | |
| 6 | activities = service.activities() |
| 7 | |
| 8 | # Retrieve the first two activities |
| 9 | activitylist = activities.list( |
| 10 | max_results='2', scope='@self', userId='@me').execute() |
| 11 | print "Retrieved the first two activities" |
| 12 | |
| 13 | # Retrieve the next two activities |
| 14 | if activitylist: |
| 15 | activitylist = activities.list_next(activitylist).execute() |
| 16 | print "Retrieved the next two activities" |
| 17 | |
| 18 | # Add a new activity |
| 19 | new_activity_body = { |
| 20 | 'title': 'Testing insert', |
| 21 | 'object': { |
| 22 | 'content': |
| 23 | u'Just a short note to show that insert is working. ☄', |
| 24 | 'type': 'note'} |
| 25 | } |
| 26 | activity = activities.insert(userId='@me', body=new_activity_body).execute() |
| 27 | print "Added a new activity" |
| 28 | |
| 29 | activitylist = activities.list( |
| 30 | max_results='2', scope='@self', userId='@me').execute() |
| 31 | |
| 32 | # Add a comment to that activity |
| 33 | comment_body = { |
| 34 | "content": "This is a comment" |
| 35 | } |
| 36 | item = activitylist['items'][0] |
| 37 | comment = service.comments().insert( |
| 38 | userId=item['actor']['id'], postId=item['id'], body=comment_body |
| 39 | ).execute() |
| 40 | print 'Added a comment to the new activity' |
| 41 | pprint.pprint(comment) |