Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Bundit J authored and Bundit J committed Oct 8, 2016
1 parent b1cd354 commit e708138
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 1 deletion.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2016 Bundit J.
Copyright (c) 2016 Bundit Jitkongchuen

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# linebot

LINE Messaging API for Node.js

[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]

## About LINE Messaging API

Please refer to the official API documents for details.

https://devdocs.line.me

## Installation

```
$ npm install linebot --save
```

## License

[MIT](LICENSE)

[npm-image]: https://img.shields.io/npm/v/linebot.svg
[npm-url]: https://npmjs.org/package/linebot
[downloads-image]: https://img.shields.io/npm/dm/linebot.svg
[downloads-url]: https://npmjs.org/package/linebot
49 changes: 49 additions & 0 deletions examples/echo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*jslint node: true, es5: true*/

'use strict';

var express = require('express');
var bodyParser = require('body-parser');
var fetch = require('node-fetch');

var app = express();
app.use(bodyParser.json());

app.get('/', function (req, res) {
res.send('Hello World!');
});

app.post('/linewebhook', function (req, res) {
console.log(req.body);
var headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + process.env.ACCESS_TOKEN
},
body = {
replyToken: req.body.events[0].replyToken,
messages: [
{
type: "text",
text: "Hello, user"
}
]
};
console.log(headers);
console.log(body);
fetch('https://api.line.me/v2/bot/message/reply', { method: 'POST', headers: headers, body: JSON.stringify(body) })
.then(function (res) {
console.log('Success');
console.log(res);
return res.json({});
})
.catch(function (err) {
console.log('Error');
console.log(err);
return res.json({});
});
});

app.listen(process.env.PORT || 80, function () {
console.log('Running');
});
2 changes: 2 additions & 0 deletions iisnode.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
loggingEnabled: true
devErrorsEnabled: true
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*jslint node: true*/
'use strict';

module.exports = {};
4 changes: 4 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*jslint node: true*/
'use strict';

module.exports = {};

0 comments on commit e708138

Please sign in to comment.