Skip to content

hanzoai/gochimp3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

6051f77 Β· Nov 27, 2024
Feb 17, 2021
Sep 1, 2016
Aug 31, 2016
Aug 31, 2016
Jul 12, 2020
Dec 3, 2020
Apr 5, 2019
Dec 3, 2020
Aug 31, 2016
Dec 3, 2020
Dec 3, 2020
Dec 3, 2020
Sep 7, 2024
Mar 3, 2021
Dec 3, 2020
Feb 17, 2021
Feb 17, 2021
Jan 8, 2021
Sep 3, 2020
Sep 3, 2016
Mar 5, 2021
Feb 17, 2021
Dec 3, 2020
Dec 3, 2020
Dec 3, 2020
Dec 3, 2020
Dec 3, 2020
Dec 3, 2020

Repository files navigation

gochimp3

GoDoc Build Status Gitter chat

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)