-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
49 lines (39 loc) · 890 Bytes
/
main.go
File metadata and controls
49 lines (39 loc) · 890 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"flag"
"fmt"
"os"
"github.com/minchao/go-mitake"
)
func usage() {
fmt.Fprintln(os.Stderr, `Usage: send [options]`)
flag.PrintDefaults()
}
func main() {
var (
username string
password string
to string
message string
)
flag.StringVar(&username, "u", os.Getenv("MITAKE_USERNAME"), "Username")
flag.StringVar(&password, "p", os.Getenv("MITAKE_PASSWORD"), "Password")
flag.StringVar(&to, "t", "", "Destination phone number, for example: 0987654321")
flag.StringVar(&message, "m", "", "Message content")
flag.Usage = usage
flag.Parse()
if len(os.Args) < 3 {
flag.Usage()
os.Exit(1)
}
sms := mitake.NewClient(username, password, nil)
resp, err := sms.Send(mitake.Message{
Dstaddr: to,
Smbody: message,
})
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
fmt.Fprintf(os.Stdout, "result: %+v\n", resp.INI)
}