Coder Social home page Coder Social logo

go-mitake's Introduction

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

go-mitake's People

Contributors

appleboy avatar bestpika avatar dependabot[bot] avatar minchao avatar tungsheng avatar ycdesu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

go-mitake's Issues

ClientID 不是純英數會造成 panic 及更新 API 到文件 v2.08 版

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x8eca9b]

goroutine 1 [running]:
github.com/minchao/go-mitake.parseMessageResponseByPattern(0xa09022, 0x12, 0x279f0240, 0xc000519760, 0x0, 0x0, 0x0)
	d:/tmp/riverland-sms-backend/src/vendor/github.com/minchao/go-mitake/message.go:173 +0x42b
github.com/minchao/go-mitake.parseLongMessageResponse(0x279f0240, 0xc000519760, 0x0, 0x0, 0x0)
	d:/tmp/riverland-sms-backend/src/vendor/github.com/minchao/go-mitake/message.go:193 +0x80
github.com/minchao/go-mitake.(*Client).SendLongMessageBatch(0xc000154050, 0xc000435b80, 0x1, 0x1, 0x0, 0x0, 0x0)
	d:/tmp/riverland-sms-backend/src/vendor/github.com/minchao/go-mitake/api.go:55 +0x591
github.com/minchao/go-mitake.(*Client).SendLongMessage(0xc000154050, 0x0, 0x0, 0xc000422422, 0xa, 0x0, 0x0, 0xc0000b0000, 0x1bb, 0xc000422438, ...)
	d:/tmp/riverland-sms-backend/src/vendor/github.com/minchao/go-mitake/api.go:65 +0x101
main.main()
	d:/tmp/riverland-sms-backend/src/main.go:90 +0x5ef
Process exiting with code: 0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.