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: "Message ...",
}
response, err := client.Send(message)
Send multiple SMS:
messages := []mitake.Message{
{
Dstaddr: "0987654321",
Smbody: "Message ...",
},
// ...
}
response, err := client.SendBatch(messages)
Send an long SMS:
message := mitake.Message{
Dstaddr: "0987654321",
Smbody: "Long message ...",
}
response, err := client.SendLongMessage(message)
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).