0.0.3 • Published 7 years ago

line-bot-api v0.0.3

Weekly downloads
6
License
MIT
Repository
github
Last release
7 years ago

line-bot-sdk-node

Build Status js-standard-style

About the LINE Messaging API

See the official API reference documentation for more information.

https://devdocs.line.me/

Usage:

const LineBot = require("line-bot")

const client = new LineBot({
  channelToken: '<insert client token>',
  channelSecret: '<insert client secret>'
})

// Using Express
app.post('/', bodyParser.json({ verify: (req, res, buf) => req.rawBody = buf }), (req, res) => {

  if (!client.validateSignature(req.rawBody, req.headers['x-line-signature'])) {
    res.sendStatus(400);
    return
  }

  // Retrieve the request's body and parse it as JSON
  const eventJson = JSON.parse(req.body);
  // Do something with eventJson
  res.sendStatus(200);
})

// Send message to user
const message = {
  type: 'text',
  text: 'hello'
}
client.pushMessage("<to>", message)
  .then((response) => {
    console.log(response)
  })
  .catch((response) => {
    console.log(response.body)
    console.log(response.status)
  })

// Send messages to user
const messages = [
  {
      "type":"text",
      "text":"Hello, world1"
  },
  {
      "type":"text",
      "text":"Hello, world2"
  }
]
client.pushMessage("<to>", messages)
0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago