如何使用Golang的github.com/google/google-api-go-client/customsearch/v1

时间:2016-02-04 18:40:31

标签: api go

我已经完成了Oauth回调,人们说它不需要,只需要cx代码,但我还没有弄清楚如何将cx参数添加到调用中。

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())

}

我知道要将视频上传到youtube你在do()之前添加参数但是你如何计算出格式?例如:

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

1 个答案:

答案 0 :(得分:1)

CseListCall结构具有Cx方法,可让您添加该参数:https://godoc.org/google.golang.org/api/customsearch/v1#CseListCall

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