Пример #1
0
func Example() {
	client := xesende.New("*****@*****.**", "pass")

	messageID, err := sendMessage(client, "538734", "Hey")
	if err != nil {
		log.Fatal(err)
	}

	for i := range []int{0, 1, 2, 3, 4, 5} {
		status, err := getStatus(client, messageID)
		if err != nil {
			log.Fatal(err)
		}

		log.Printf("message status after %d seconds: %s\n", i, status)
		time.Sleep(time.Second)
	}
}
Пример #2
0
func main() {
	flag.Parse()

	if *username == "" {
		*username = os.Getenv("ESENDEX_USERNAME")
	}

	if *password == "" {
		*password = os.Getenv("ESENDEX_PASSWORD")
	}

	if *account == "" {
		*account = os.Getenv("ESENDEX_ACCOUNT")
	}

	if *username == "" || *password == "" {
		log.Fatal(authHelp)
	}

	client := xesende.New(*username, *password)

	commands := hadfield.Commands{
		receivedCmd(client),
		sentCmd(client),
		messageCmd(client),
		accountsCmd(client),
	}

	if *account == "" {
		commands = append(commands,
			receivedCmd(client),
			sentCmd(client))
	} else {
		accountClient := client.Account(*account)

		commands = append(commands,
			receivedCmd(accountClient),
			sentCmd(accountClient),
			sendCmd(accountClient))
	}

	hadfield.Run(commands, templates)
}