1
0
mirror of https://github.com/nikoksr/notify.git synced 2025-02-15 13:33:26 +02:00

docs: add line service example usage

This commit is contained in:
Yoel Susanto 2021-02-23 17:19:24 +07:00
parent b4922a64e6
commit c511ac19ee

43
service/line/usage.md Normal file
View File

@ -0,0 +1,43 @@
# Line Usage
Install notifier using:
* `go get -u github.com/nikoksr/notify`
## Sample Code
```go
package main
import (
"github.com/nikoksr/notify"
"github.com/nikoksr/notify/service/line"
"golang.org/x/net/context"
)
func main() {
// Assuming you already have a line messaging API credential
// Provide your channel secret and access token
lineService, _ := line.New("channelSecret", "channelAccessToken")
// Add id from various receivers
// You can try to use your own line id for testing
lineService.AddReceivers("userID1", "groupID1")
notifier := notify.New()
// Tell our notifier to use the line service. You can repeat the above process
// for as many services as you like and just tell the notifier to use them.
notifier.UseServices(lineService)
// Send a message
err := notifier.Send(context.Background(),
"Welcome",
"I am a bot written in Go!",
)
if err != nil {
panic(err)
}
}
```