Skip to content

Commit

Permalink
Fix example and remove false deprecated message (#374)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yang-33 authored Oct 31, 2023
1 parent e001d62 commit 8497d18
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@ This library requires Go 1.11 or later.
$ go get -u github.com/line/line-bot-sdk-go/v7/linebot
```

## Import all packages in your code ##
```go
import (
"github.com/line/line-bot-sdk-go/v7/linebot"
"github.com/line/line-bot-sdk-go/v7/linebot/channel_access_token"
"github.com/line/line-bot-sdk-go/v7/linebot/httphandler"
"github.com/line/line-bot-sdk-go/v7/linebot/insight"
"github.com/line/line-bot-sdk-go/v7/linebot/liff"
"github.com/line/line-bot-sdk-go/v7/linebot/manage_audience"
"github.com/line/line-bot-sdk-go/v7/linebot/messaging_api"
"github.com/line/line-bot-sdk-go/v7/linebot/module"
"github.com/line/line-bot-sdk-go/v7/linebot/module_attach"
"github.com/line/line-bot-sdk-go/v7/linebot/shop"
"github.com/line/line-bot-sdk-go/v7/linebot/webhook"
)

```

## Configuration ##

```go
Expand Down Expand Up @@ -65,7 +83,7 @@ import (
"github.com/line/line-bot-sdk-go/v7/linebot/webhook"
)

cb, err := webhook.ParseRequest(req)
cb, err := webhook.ParseRequest(os.Getenv("LINE_CHANNEL_SECRET"), req)
if err != nil {
// Handle any errors that occur.
}
Expand All @@ -85,6 +103,16 @@ for _, event := range cb.Events {
}
```

We provide code [examples](./examples).
- [EchoBot](./examples/echo_bot/server.go)
- a simple echo bot
- [KitchenSink](./examples/kitchensink/server.go)
- a bot that handles many types of events
- [EchoBotHandler](./examples/echo_bot_handler/server.go)
- [DeliveryHelper](./examples/delivery_helper/main.go)
- [InsightHelper](./examples/insight_helper/main.go)
- [RichmenuHelper](./examples/richmenu_helper/main.go)

### Receiver ###

To send a message to a user, group, or room, you need either an ID
Expand Down
2 changes: 0 additions & 2 deletions linebot/webhook/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ var (
)

// ParseRequest func
// Deprecated: Use OpenAPI based classes instead.
func ParseRequest(channelSecret string, r *http.Request) (*CallbackRequest, error) {
defer func() { _ = r.Body.Close() }()
body, err := io.ReadAll(r.Body)
Expand All @@ -33,7 +32,6 @@ func ParseRequest(channelSecret string, r *http.Request) (*CallbackRequest, erro
return &cb, nil
}

// Deprecated: Use OpenAPI based classes instead.
func ValidateSignature(channelSecret, signature string, body []byte) bool {
decoded, err := base64.StdEncoding.DecodeString(signature)
if err != nil {
Expand Down

0 comments on commit 8497d18

Please sign in to comment.