apigogoogle-api-go-client

How to use Golang's github.com/google/google-api-go-client/customsearch/v1


I've done the Oauth callback from which people said it's not needed, and just needs the cx code but I have yet to figure out how to add the cx parameter to the call.

package main

import (
    "fmt"
    "log"

    "github.com/vinniyo/authCallback"

    "github.com/google/google-api-go-client/customsearch/v1"
)

func main() {
    client, err := authCallback.BuildOAuthHTTPClient()
    if err != nil {
        log.Fatalf("Error building OAuth client: %v", err)
    }

    service, err := customsearch.New(client)
    if err != nil {
        log.Fatalf("Error creating YouTube client: %v", err)
    }

    fmt.Println(service.Cse.List("bob").Do())

}

I know to upload a video to youtube you add parameters before do() but how do you figure out the formatting? eg:

    upload := &youtube.Query{
        Status: &youtube.VideoStatus{PrivacyStatus: *privacy},
    } 

Solution

  • The CseListCall struct has Cx method which lets you add that parameter: https://godoc.org/google.golang.org/api/customsearch/v1#CseListCall

    fmt.Println(service.Cse.List("bob").Cx("my_cx_id").Do())