Skip to content
forked from minchao/go-mitake

Mitake SMS library for Golang (Unofficial)

License

Notifications You must be signed in to change notification settings

mitaketw/sms-go

 
 

Repository files navigation

go-mitake

GoDoc Build Status Go Report Card codecov

go-mitake is a Go client library for accessing the Mitake SMS API (Taiwan mobile phone number only).

Installation

go get -u github.com/minchao/go-mitake

Usage

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)
}

License

See the LICENSE file for license rights and limitations (MIT).

About

Mitake SMS library for Golang (Unofficial)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%