mirror of
https://github.com/hanzoai/gochimp3.git
synced 2026-10-30 18:35:57 +00:00
main
Superseded: the Hanzo GitHub App pushes a webhook, so the forge tracks GitHub without a per-repo workflow. This file called git.hanzo.ai/api/v1/.../mirror-sync β a Gitea API for a system we no longer drive β and would sit inert in every repo. One mechanism, in one place, instead of ~350 copies of a cron.
gochimp3
Introduction
Golang client for MailChimp API 3.0.
Install
Install with go get:
$ go get github.com/hanzoai/gochimp3
Usage
package main
import (
"fmt"
"os"
"github.com/hanzoai/gochimp3"
)
const (
apiKey = "YOUR_API_KEY_HERE"
)
func main() {
client := gochimp3.New(apiKey)
// Audience ID
// https://mailchimp.com/help/find-audience-id/
listID := "7f12f9b3fz"
// Fetch list
list, err := client.GetList(listID, nil)
if err != nil {
fmt.Printf("Failed to get list %s", listID)
os.Exit(1)
}
// Add subscriber
req := &gochimp3.MemberRequest{
EmailAddress: "[email protected]",
Status: "subscribed",
}
if _, err := list.CreateMember(req); err != nil {
fmt.Printf("Failed to subscribe %s", req.EmailAddress)
os.Exit(1)
}
}
Set Timeout
client := gochimp3.New(apiKey)
client.Timeout = (5 * time.Second)
Languages
Go
100%