Skip to content

Commit

Permalink
Merge pull request #2 from spaske/master
Browse files Browse the repository at this point in the history
DLR section in README
  • Loading branch information
HORISEN AG authored Mar 1, 2019
2 parents eb66d27 + f365bd9 commit c07578e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.swp
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"

...

Expand All @@ -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",
Expand All @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"net/http"
"time"

"github.com/horisen/smsgate-clientlib-golang/smsgate"
"github.com/horisen/smsgate-smshttpclient-golang/smsgate"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion smsgate/examples/example-sendsms/example_sendsms.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"flag"
"log"

"github.com/horisen/smsgate-clientlib-golang/smsgate"
"github.com/horisen/smsgate-smshttpclient-golang/smsgate"
)

var (
Expand Down

0 comments on commit c07578e

Please sign in to comment.