go-mitake is a Go client library for accessing the Mitake SMS API (Taiwan mobile phone number only).
go get -u github.com/minchao/go-mitake
import "github.com/minchao/go-mitake"
Construct a new Mitake SMS client, then use to access the Mitake API. For example:
client := mitake.NewClient("USERNAME", "PASSWORD", nil)
// Retrieving your account balance
balance, err := client.QueryAccountPoint()
Send an SMS:
message := mitake.Message{
Dstaddr: "0987654321",
Smbody: "Test SMS",
}
response, err := client.Send(message)
Send multiple SMS:
messages := []mitake.Message{
{
Dstaddr: "0987654321",
Smbody: "Test SMS",
},
// ...
}
response, err := client.SendBatch(messages)
Query the status of messages:
response, err := client.QueryMessageStatus([]string{"MESSAGE_ID1", "MESSAGE_ID2"})
Use webhook to receive the delivery receipts of the messages:
http.HandleFunc("/callback", func(w http.ResponseWriter, r *http.Request) {
receipt, err := mitake.ParseMessageReceipt(r)
if err != nil {
// Handle error...
return
}
// Process message receipt...
})
// The callback URL port number must be standard 80 (HTTP) or 443 (HTTPS).
if err := http.ListenAndServe(":80", nil); err != nil {
log.Printf("ListenAndServe error: %v", err)
}
See the LICENSE file for license rights and limitations (MIT).