A Go client library for accessing the EVERY8D SMS API.
Use go get to install.
go get -u github.com/minchao/go-every8d
Import the go-every8d
package.
import "github.com/minchao/go-every8d"
Construct a new API client, then use to access the EVERY8D API. For example:
client := every8d.NewClient("UID", "PWD", nil)
message := every8d.Message{
Subject: "Note",
Content: "Hello, 世界",
Destination: "+886987654321",
}
result, err := client.Send(context.Background(), message)
resp, err := client.GetDeliveryStatus(context.Background(), batchID, pageNo)
Retrieve your account balance.
credit, err := client.GetCredit(context.Background())
func main() {
http.HandleFunc("/callback", func(w http.ResponseWriter, r *http.Request) {
report, err := every8d.ParseReportMessage(r)
if err != nil {
// Handle error...
return
}
// Process report message...
})
if err := http.ListenAndServe(":8080", nil); err != nil {
log.Printf("ListenAndServe error: %v", err)
}
}
Change directory to cmd/every8d, and build the tool:
$ cd cmd/every8d
$ go build
Run:
$ ./every8d
EVERY8D SMS CLI tool
Usage:
every8d [command]
Available Commands:
credit Query credit
delivery-status Query to retrieve the delivery status
help Help about any command
send Send an SMS
send-mms Send an MMS
webhook Webhook to receive the sending report and reply message
Flags:
-h, --help help for every8d
--password string EVERY8D Password
--username string EVERY8D Username
Use "every8d [command] --help" for more information about a command.
Example to send SMS:
$ ./every8d send --username=0987654321 --password=password --dest=0987654321 --msg="Hello, 世界"
Credit: 79.00
Sent: 1
Cost: 1.00
Unsent: 0
BatchID: 00000000-00000-0000-0000-000000000000
$ go test -v -race .
This library is distributed under the BSD-style license found in the LICENSE file.