diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1377554 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.swp diff --git a/README.md b/README.md index 485275b..8e48afb 100644 --- a/README.md +++ b/README.md @@ -5,13 +5,13 @@ Install GO library ``` -go get github.com/horisen/smsgate-clientlib-golang/smsgate +go get github.com/horisen/smsgate-smshttpclient-golang/smsgate ``` ## Send SMS ```golang -import "github.com/horisen/smsgate-clientlib-golang/smsgate" +import "github.com/horisen/smsgate-smshttpclient-golang/smsgate" ... @@ -26,6 +26,8 @@ sms := &smsgate.SMSRequest{ Text: paramText, DCS: smsgate.DCSGSM, + DlrMask: smsgate.DLRMaskStandard, + DlrURL: "http://YOUR-SERVER-IP:YOUR-SERVER-PORT/dlr", Auth: &smsgate.Auth{ Username: "YOUR-USERNAME", @@ -47,3 +49,27 @@ if err != nil { response.MsgID, response.NumParts) } ``` + +## Receive DLRs + +```golang + mux := http.NewServeMux() + mux.HandleFunc("/dlr", func(w http.ResponseWriter, req *http.Request) { + dlr, err := api.ParseDeliveryReport(req) + if err != nil { + log.Printf("Cannot parse DLR: %s\n", err) + } + log.Printf("Received DLR: %#v\n", dlr) + }) + + httpsrv := &http.Server{ + Addr: ":YOUR-SERVER-PORT", + Handler: mux, + ReadTimeout: 10 * time.Minute, + WriteTimeout: 10 * time.Minute, + MaxHeaderBytes: 1 << 20, + } + log.Fatal(httpsrv.ListenAndServe()) +``` + +Check `examples` directory. diff --git a/smsgate/examples/example-sendsms-with-dlr/example_sendsms_with_dlr.go b/smsgate/examples/example-sendsms-with-dlr/example_sendsms_with_dlr.go index 2488e71..38c7444 100644 --- a/smsgate/examples/example-sendsms-with-dlr/example_sendsms_with_dlr.go +++ b/smsgate/examples/example-sendsms-with-dlr/example_sendsms_with_dlr.go @@ -8,7 +8,7 @@ import ( "net/http" "time" - "github.com/horisen/smsgate-clientlib-golang/smsgate" + "github.com/horisen/smsgate-smshttpclient-golang/smsgate" ) const ( diff --git a/smsgate/examples/example-sendsms/example_sendsms.go b/smsgate/examples/example-sendsms/example_sendsms.go index d401f2c..9a4072d 100644 --- a/smsgate/examples/example-sendsms/example_sendsms.go +++ b/smsgate/examples/example-sendsms/example_sendsms.go @@ -4,7 +4,7 @@ import ( "flag" "log" - "github.com/horisen/smsgate-clientlib-golang/smsgate" + "github.com/horisen/smsgate-smshttpclient-golang/smsgate" ) var (