-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from Kif11/master
Fixed missing listID variable and replaced println with printf
- Loading branch information
Showing
1 changed file
with
18 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,34 +16,38 @@ $ go get github.com/hanzoai/gochimp3 | |
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/hanzoai/gochimp3" | ||
"github.com/hanzoai/gochimp3" | ||
) | ||
|
||
const ( | ||
apiKey = "f6f6eb412g2b9677b00550d14d86db5e-us4" | ||
apiKey = "YOUR_API_KEY_HERE" | ||
) | ||
|
||
func main() { | ||
client := gochimp3.New(apiKey) | ||
client := gochimp3.New(apiKey) | ||
|
||
// Fetch list | ||
list, err := client.GetList("28a3d7a5", nil) | ||
// Audience ID | ||
// https://mailchimp.com/help/find-audience-id/ | ||
listID := "7f12f9b3fz" | ||
|
||
// Fetch list | ||
list, err := client.GetList(listID, nil) | ||
if err != nil { | ||
fmt.Println("Failed to get list '%s'", listId) | ||
fmt.Printf("Failed to get list %s", listID) | ||
os.Exit(1) | ||
} | ||
|
||
// Add subscriber | ||
req := &gochimp3.MemberRequest{ | ||
EmailAddress: "[email protected]", | ||
Status: "subscribed", | ||
} | ||
// Add subscriber | ||
req := &gochimp3.MemberRequest{ | ||
EmailAddress: "[email protected]", | ||
Status: "subscribed", | ||
} | ||
|
||
if _, err := list.CreateMember(req); err != nil { | ||
fmt.Println("Failed to subscribe '%s'", req.EmailAddress) | ||
fmt.Printf("Failed to subscribe %s", req.EmailAddress) | ||
os.Exit(1) | ||
} | ||
} | ||
|