abujehad139 / google-api-go-client

Automatically exported from code.google.com/p/google-api-go-client
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

more examples #3

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
ideally one example per API

Original issue reported on code.google.com by bradfitz@google.com on 25 Aug 2011 at 9:10

GoogleCodeExporter commented 9 years ago
I was working with the G+ history (moments) API and wanted to see how to use it 
with the Go API:

# HG changeset patch
# User Chris Christensen <christianchristensen@gmail.com>
# Date 1356769539 21600
# Node ID 11ce5b2dc2eda08a0cd65f5e4a375b2cacbab3ff
# Parent  7bfdc57efcf214d72b243efe89bd83fce2ffaed3
Add Google+ History API example.

diff -r 7bfdc57efcf2 -r 11ce5b2dc2ed examples/plusmoments.go
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/plusmoments.go   Sat Dec 29 02:25:39 2012 -0600
@@ -0,0 +1,28 @@
+package main
+
+import (
+   "fmt"
+   "net/http"
+   "strings"
+
+   plusmoment "code.google.com/p/google-api-go-client/plus/v1moments"
+)
+
+func init() {
+   s := []string{plusmoment.PlusMomentsWriteScope, plusmoment.PlusMeScope}
+   registerDemo("plusmoment", strings.Join(s, " "), plusMomentsMain)
+}
+
+func plusMomentsMain(client *http.Client, argv []string) {
+   svc, _ := plusmoment.New(client)
+   
+   // Example from rom https://developers.google.com/+/history/#writing_moments
+   svc.Moments.Insert("me", "vault", &plusmoment.Moment{
+       Type: "http://schemas.google.com/ViewActivity",
+       Target: &plusmoment.ItemScope{
+           Url: "http://www.youtube.com/watch?v=6y_xKVSRAy8",
+       },
+   }).Do()
+
+   fmt.Printf("Moment written: https://plus.google.com/history.\n")
+}

Original comment by christianchristensen on 29 Dec 2012 at 8:27

GoogleCodeExporter commented 9 years ago
Closing - migrated to Github:
https://github.com/google/google-api-go-client/issues/4

Original comment by gmle...@google.com on 29 Mar 2015 at 3:02

GoogleCodeExporter commented 9 years ago
Reopening issue for auto-migration to Github.

Original comment by gmle...@google.com on 29 Mar 2015 at 10:44