1
0
mirror of https://github.com/nikoksr/notify.git synced 2025-01-10 00:28:36 +02:00
notify/service/line/usage.md

46 lines
956 B
Markdown
Raw Normal View History

2021-02-23 12:19:24 +02:00
# 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()
2021-03-06 16:03:52 +02:00
2021-02-23 12:19:24 +02:00
// 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
2021-03-06 16:03:52 +02:00
err := notifier.Send(
context.Background(),
2021-02-23 12:19:24 +02:00
"Welcome",
"I am a bot written in Go!",
)
if err != nil {
panic(err)
}
}
```