fiorix/go-smpp
关于
SMPP 3.4 Protocol for the Go programming language
编程语言与运行时实测星标增长
- 24小时
- 0
- 7天
- +1
- 15天
- +1
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文SMPP 3.4
This is an implementation of SMPP 3.4 for Go, based on the original smpp34 from Kevin Patel.
The API has been refactored to idiomatic Go code with more tests and documentation. There are also quite a few new features, such as a test server (see smpptest package) and text codecs for GSM 7-bit (packed and unpacked), Latin-1, ISO-8859-5 and UCS-2.
It is not fully compliant, there are some TODOs in the code.
Usage
Following is an SMPP client transmitter wrapped by an HTTP server that can send Short Messages (SMS):
func main() {
// make persistent connection
tx := &smpp.Transmitter{
Addr: "localhost:2775",
User: "foobar",
Passwd: "secret",
}
conn := tx.Bind()
// check initial connection status
var status smpp.ConnStatus
if status = <-conn; status.Error() != nil {
log.Fatalln("Unable to connect, aborting:", status.Error())
}
log.Println("Connection completed, status:", status.Status().String())
// example of connection checker goroutine
go func() {
for c := range conn {
log.Println("SMPP connection status:", c.Status())
}
}()
// example of sender handler func
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
sm, err := tx.Submit(&smpp.ShortMessage{
Src: r.FormValue("src"),
Dst: r.FormValue("dst"),
Text: pdutext.Raw(r.FormValue("text")),
Register: pdufield.NoDeliveryReceipt,
TLVFields: pdutlv.Fields{
pdutlv.TagReceiptedMessageID: pdutlv.CString(r.FormValue("msgId")),
},
})
if err == smpp.ErrNotConnected {
http.Error(w, "Oops.", http.StatusServiceUnavailable)
return
}
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
io.WriteString(w, sm.RespID())
})
log.Fatal(http.ListenAndServe(":8080", nil))
}
You can test from the command line:
curl localhost:8080 -X GET -F src=bart -F dst=lisa -F text=hello
If you don't have an SMPP server to test, check out Selenium SMPPSim. It has been used for the development of this package.
Tools
The cmd/sms directory provides a command line client for sending
short messages and querying message status against an SMSC.
For an HTTP API server built on top of this library, see sms-api-server.
Supported PDUs
- bind_transmitter
- bind_transmitter_resp
- bind_receiver
- bind_receiver_resp
- bind_transceiver
- bind_transceiver_resp
- outbind
- unbind
- unbind_resp
- submit_sm
- submit_sm_resp
- submit_sm_multi
- submit_sm_multi_resp
- data_sm
- data_sm_resp
- deliver_sm
- deliver_sm_resp
- query_sm
- query_sm_resp
- cancel_sm
- cancel_sm_resp
- replace_sm
- replace_sm_resp
- enquire_link
- enquire_link_resp
- alert_notification
- generic_nack
- tag-length-value (TLV)
Copyright
See the LICENSE file for details. Contributors are listed in the
git history; run git shortlog -sn for the current list.
探索相关项目
加载中…