(Go) List all Labels in the User's Mailbox
List all Labels in the GMail User's Mailbox
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
var success bool
http := chilkat.NewHttp()
http.SetAuthToken("GMAIL-ACCESS-TOKEN")
userId := "me"
http.SetUrlVar("userId",userId)
url := "https://www.googleapis.com/gmail/v1/users/{$userId}/labels"
http.SetSessionLogFilename("c:/temp/qa_output/sessionLog.txt")
// Get the list of GMail labels as JSON.
sb := chilkat.NewStringBuilder()
success = http.QuickGetSb(url,sb)
if success != true {
fmt.Println(http.LastErrorText())
http.DisposeHttp()
sb.DisposeStringBuilder()
return
}
json := chilkat.NewJsonObject()
json.LoadSb(sb)
json.SetEmitCompact(false)
fmt.Println(*json.Emit())
if http.LastStatus() != 200 {
fmt.Println("Failed.")
http.DisposeHttp()
sb.DisposeStringBuilder()
json.DisposeJsonObject()
return
}
http.DisposeHttp()
sb.DisposeStringBuilder()
json.DisposeJsonObject()
|